I wrote a go test file in a package then run go test ./... to execute all tests.
The problem is some test need app config which is stored in .yaml file in project root dir. Normally when I run main.go file in root, it works well since the current working dir os.Getwd() will be the root dir. But when running test, the current working dir becomes the test file path which make the config file cannot be found.
I was thinking of 2 solution:
- Initialize config before for all tests
- Update the config init function to use to project root dir instead of current working dir
I tried searching but haven't found any solution yet.
Thank you in advance!