-
Notifications
You must be signed in to change notification settings - Fork 162
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
mocks: update list, fix unexported interfaces in bfd #3878
Conversation
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.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @matzf)
go/pkg/router/bfd/export_test.go, line 48 at r1 (raw file):
State = state Event = event Source = source
Why are these changes needed?
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.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @oncilla)
go/pkg/router/bfd/export_test.go, line 48 at r1 (raw file):
Previously, Oncilla (Dominik Roos) wrote…
Why are these changes needed?
mockgen does not see the Source
and IntervalGenerator
types, as they are only exported in this _test.go
file.
It also refuses to create mocks for the unexported interfaces. I don't think there is a way to make these interfaces visible to mockgen and at the same time keep them private -- at least not in the "reflect" mode of mockgen.
Not sure how creating the checked in mocks was accomplished, maybe just manually export interface, run mockgen and then change it back to private?
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.
Reviewed 3 of 3 files at r1.
Reviewable status: complete! all files reviewed, all discussions resolved
go/pkg/router/bfd/export_test.go, line 48 at r1 (raw file):
Previously, matzf (Matthias Frei) wrote…
mockgen does not see the
Source
andIntervalGenerator
types, as they are only exported in this_test.go
file.
It also refuses to create mocks for the unexported interfaces. I don't think there is a way to make these interfaces visible to mockgen and at the same time keep them private -- at least not in the "reflect" mode of mockgen.
Not sure how creating the checked in mocks was accomplished, maybe just manually export interface, run mockgen and then change it back to private?
Hm, yeah this looks a bit awkward. It's a bit unfortunate that gomock does not see the _test.go
files. But I guess it makes sense.
Conceptually, I think it is cleaner to hide these interfaces, since they solely exist for testing.
You could actually do it with a second definition of the same interface in go/pkg/router/bfd/internal/
and then apply mockgen on that. But IMO I don't think that is worth the effort.
go/pkg/router/bfd/jitter.go, line 67 at r1 (raw file):
} // IntervalGenerator generates integers in [x, y). It panics if x < 0 or if y <= x.
Interesting, it looks like this was public once, and then hidden. 🕵️
Same for source.
/rebase |
244516d
to
b99c1e4
Compare
During various refactors (e.g. #3862), some of the mocks were updated without updating the list of mock targets in
tools/gomocks
. Fixed by semi-manually syncing the mock target list with the actually existing mocks.The interfaces in
go/pkg/router/bfd/
were not directly exported and gomock refused to generate the mock code.This change is