-
Notifications
You must be signed in to change notification settings - Fork 800
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
Add tests for common/cache/domainCache.go #6431
Add tests for common/cache/domainCache.go #6431
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted filessee 51 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
s.domainCache.Start() | ||
|
||
s.domainCache.Stop() | ||
s.Equal(domainCacheStopped, s.domainCache.status) |
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 might have missed but if there's no test covering the following scenario let's add it:
Start()
calls the refreshLoop in background which is validated by advancing time and checking new domains after refresh occured.
common/cache/domainCache_test.go
Outdated
|
||
failoverEndTime := common.Int64Ptr(40) | ||
|
||
entry := &DomainCacheEntry{ |
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.
In general, this is hard to ensure it'll stay up to date. If you need, you can use common/testing/testdatagen
or the package it uses directly (github.com/google/gofuzz
) to generate test data which will fill out the entire struct. Then after storing it or whatever and getting it back, just ensuring it's equal to the original data (taking care about deep-copying i guess) should ensure that this will evolve.
this may not work here where there's lots of private structs, atomics etc. so this is general and maybe not accurate in all cases
What changed?
Added tests for common/cache/domainCache.go
Why?
Code coverage
How did you test it?
Unit tests
Potential risks
Release notes
Documentation Changes