Closed wissam closed 1 year ago
I'm not sure what the best workaround for this is without putting the exact same logic in the tests that the tests are supposed to be testing as that would make the tests useless. I'm open to suggestions if you have any.
My priority is that these pass on CI using the OS matrix strategy available on Github Actions, which is why I've hardcoded it to runner. This is similarly done on macOS and Windows.
For now as a workaround, you can do a find and replace locally for all _linux
test files and change the tests locally to say wissam
instead of runner
and not commit the name change. As of now, these should be limited to the utils package. That should unblock you for now so you can contribute your changes upstream. You can use a Git tool like the TUI tig (this is what I use) or the GUI SourceTree or another Git tool that allows you to stage line-by-line to stage selective pieces of code, omitting these username changes. This will allow you to make the necessary changes locally so that you can see your tests pass but allow you to commit your new tests without committing the username changes. This is what I do locally when testing, as my name is also not runner. 😅
Arguably only the method ConfigFilePath()
needs to be tested since the other test only calls os.UserConfigDir()
and that doesn't need to be tested since it's standard library. The goal of the tests is to ensure we are writing to timerrr/timers.json
in the user config directory for each operating system.
What do other Go projects do in cases like this? Do they leave this untested? Do they write to a path outside of the user's home directory instead?
Thanks! I will check both tig and sourcetree !
When you run tests , the user/home dirs are hardcoded as "runner"