Skip to content
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

Merged
merged 4 commits into from
Oct 30, 2024

Conversation

fimanishi
Copy link
Contributor

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

Copy link

codecov bot commented Oct 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.70%. Comparing base (692319c) to head (b724668).
Report is 26 commits behind head on master.

Additional details and impacted files

see 51 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 692319c...b724668. Read the comment docs.

s.domainCache.Start()

s.domainCache.Stop()
s.Equal(domainCacheStopped, s.domainCache.status)
Copy link
Contributor

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.


failoverEndTime := common.Int64Ptr(40)

entry := &DomainCacheEntry{
Copy link
Contributor

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

@fimanishi fimanishi merged commit 12cc0eb into uber:master Oct 30, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants