-
Notifications
You must be signed in to change notification settings - Fork 208
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
connectivity: Add GetTestOrDie() #2096
Conversation
Add a convenient function GetTestOrDie(). There isn't much you can do if GetTest() fails anyways. Signed-off-by: Michi Mutsuzaki <[email protected]>
@@ -293,6 +293,16 @@ func (ct *ConnectivityTest) GetTest(name string) (*Test, error) { | |||
panic("missing test descriptor for a registered name") | |||
} | |||
|
|||
// GetTestOrDie returns the test scope for test named "name" if found, | |||
// or panics otherwise. | |||
func (ct *ConnectivityTest) GetTestOrDie(name string) *Test { |
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.
nit: the upstream convention for functions that panic on failure is usually MustFoo
(see e.g. netip.MustParseAddr
), so this could be named MustGetTest
instead.
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.
✨ #2098 ✨
Fixes: 89c7ff0 ("connectivity: Add GetTestOrDie()") Ref: #2096 (review) Signed-off-by: Michi Mutsuzaki <[email protected]>
Fixes: 89c7ff0 ("connectivity: Add GetTestOrDie()") Ref: #2096 (review) Signed-off-by: Michi Mutsuzaki <[email protected]>
Fixes: 89c7ff04254f ("connectivity: Add GetTestOrDie()") Ref: cilium/cilium-cli#2096 (review) Signed-off-by: Michi Mutsuzaki <[email protected]>
[ cherry-picked from cilium/cilium-cli repository ] Fixes: 89c7ff04254f ("connectivity: Add GetTestOrDie()") Ref: cilium/cilium-cli#2096 (review) Signed-off-by: Michi Mutsuzaki <[email protected]>
[ cherry-picked from cilium/cilium-cli repository ] Fixes: 89c7ff04254f ("connectivity: Add GetTestOrDie()") Ref: cilium/cilium-cli#2096 (review) Signed-off-by: Michi Mutsuzaki <[email protected]>
Add a convenient function GetTestOrDie(). There isn't much you can do if GetTest() fails anyways.