Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix config file handle closing and run cross platform unit tests #639

Merged
merged 14 commits into from
Feb 5, 2025

Conversation

nieomylnieja
Copy link
Collaborator

@nieomylnieja nieomylnieja commented Feb 3, 2025

Motivation

The main reason for this PR is to fix config file writing on Windows, because we were not properly closing the file handle before renaming it, this cause an error on Windows, stating that file is already used by another process.

Summary

In order to better support Linux, MacOS and Windows usages we should run the unit tests on each of them.

Release Notes

sdk.FileConfig operations which attempt to save the config file should now operate on Windows without any issues.

@nieomylnieja nieomylnieja changed the title chore: Run cross platform unit tests chore: Fix config file handling closing and run cross platform unit tests Feb 3, 2025
@nieomylnieja nieomylnieja changed the title chore: Fix config file handling closing and run cross platform unit tests fix: Fix config file handling closing and run cross platform unit tests Feb 4, 2025
@nieomylnieja nieomylnieja removed the chore label Feb 4, 2025
@n9-machine-user n9-machine-user added chore bug Something isn't working labels Feb 4, 2025
@nieomylnieja nieomylnieja changed the title fix: Fix config file handling closing and run cross platform unit tests fix: Fix config file handle closing and run cross platform unit tests Feb 4, 2025
Copy link
Contributor

@daniel-zelazny daniel-zelazny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, please consider two small suggestions :)

internal/stringutils/stringutils.go Outdated Show resolved Hide resolved
sdk/reader_test.go Show resolved Hide resolved
@nieomylnieja nieomylnieja merged commit ca99c5e into main Feb 5, 2025
7 checks passed
@nieomylnieja nieomylnieja deleted the run-cross-platform-tests branch February 5, 2025 10:43
nieomylnieja added a commit to nobl9/sloctl that referenced this pull request Feb 5, 2025
## Motivation

Currently, whenever modifying the `config.toml` file on Windows using
`sloctl config` commands an error arises:

> Error: rename C:\Users\mh\.config\nobl9\config.toml3389036250
C:\Users\mh\.config\nobl9\config.toml: The process cannot access the
file because it is being used by another process.

The issue comes from Nobl9 SDK and is fixed by
nobl9/nobl9-go#639.

## Related changes

- nobl9/nobl9-go#639

## Testing

Tested on Windows 11 23H2 run inside Virtual Box.


![image](https://github.com/user-attachments/assets/81fa4790-3195-4be9-9925-e517f9bb80e0)

## Release Notes

`sloctl config` commands which modify _config.toml_ should now work on
Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working chore go patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants