-
Notifications
You must be signed in to change notification settings - Fork 243
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
Refactoring and test fixes. #70
Refactoring and test fixes. #70
Conversation
Codecov Report
@@ Coverage Diff @@
## master #70 +/- ##
==========================================
+ Coverage 60.03% 60.98% +0.94%
==========================================
Files 18 18
Lines 1544 1548 +4
==========================================
+ Hits 927 944 +17
+ Misses 510 500 -10
+ Partials 107 104 -3
Continue to review full report at Codecov.
|
Ready to Merge, of course only after review. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks really good to me. Good job and thanks a lot! @Skarlso 🤗
I also think about having one helper function that sets up gaia.Cfg
which we can simply call on every test start up. What do you think?
Edit: We can add that btw. in another PR at another time 😄
@@ -4,7 +4,7 @@ GO_LDFLAGS_STATIC=-ldflags "-s -w -extldflags -static" | |||
default: dev | |||
|
|||
dev: | |||
go run ./cmd/gaia/main.go -homepath=${PWD}/tmp -dev=true -poll=true | |||
go run ./cmd/gaia/main.go -homepath=${PWD}/tmp -dev=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we already talked about this. I think we can leave it in. What do you think? 🤗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will just merge it in now. We can add it later again if decision has been made 🤗
This PR fixes the following:
defer func() { services.MockStorageService(nil)}()
is needed for cleanup.nil
. If not, it will just return that, but will fail never the less because the file doesn't exists like the db, or the certificate. Again, a set to nil will fix this problem.os.TempDir
isn't unique enough. There are cases now that the tests step on each other.ioutil.TempDir("", "TestName")
must be used to ensure semi uniqueness. Maybe add a random number in there.There might be more cases when running a test something doesn't work. A good first step is add in a defer mock to nil for services that the code might use. Like, vault, or storage.
Also, pro tip... once in a while run
go clean -testcache
! This will erase every cached content and force tests to run. Might surprise you that some tests start to fail even though you though they are passing. Watch out for this tid-bit:ok github.com/gaia-pipeline/gaia/handlers **(cached)**
.