I have implemented several packages for a web API, each with their own test cases. When each package is tested using go test ./api/pkgname
the tests pass. If I want to run all tests at once with go test ./api/...
test cases always fail.
In each test case, I recreate the entire schema using DROP SCHEMA public CASCADE
followed by CREATE SCHEMA public
and apply all migrations. The test suite reports errors back at random, saying a relation/table does not exist, so I guess each test suite (per package) is run in parallel somehow, thus messing up the DB state.
I tried to pass along some test flags like go test -cpu 1 -parallel 0 ./src/api/...
with no success.
Could the problem here be tests running in parallel, and if yes, how can I force serial execution?
Update:
Currently I use this workaround to run the tests, but I still wonder if there's a better solution
find <dir> -type d -exec go test {} \;