-
Notifications
You must be signed in to change notification settings - Fork 152
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 blueprint validate of kanister function with non default versions #1404
Conversation
Feels like diff --git a/pkg/blueprint/validate/validate_test.go b/pkg/blueprint/validate/validate_test.go
index 6c9ee6f2..b6e4cbc5 100644
--- a/pkg/blueprint/validate/validate_test.go
+++ b/pkg/blueprint/validate/validate_test.go
@@ -223,11 +223,14 @@ func (v *ValidateBlueprint) TestValidate(c *C) {
if tc.deferPhase != nil {
bp.Actions["backup"].DeferPhase = tc.deferPhase
}
- err := Do(bp, kanister.DefaultVersion)
- if err != nil {
- c.Assert(strings.Contains(err.Error(), tc.errContains), Equals, true)
+
+ for _, v := range []string{kanister.DefaultVersion, nonDefaultFuncVersion} {
+ err := Do(bp, v)
+ if err != nil {
+ c.Assert(strings.Contains(err.Error(), tc.errContains), Equals, true)
+ }
+ c.Assert(err, tc.err)
}
- c.Assert(err, tc.err)
}
}
@@ -373,4 +376,5 @@ var _ kanister.Func = (*nonDefaultVersionFunc)(nil)
func init() {
_ = kanister.RegisterVersion(&nonDefaultVersionFunc{}, nonDefaultFuncVersion)
+ _ = kanister.RegisterVersion(&nonDefaultVersionFunc{}, kanister.DefaultVersion)
}
|
@ihcsim I think we can optimize this as per your suggestion 👍🏼 Should we follow up later once Vivek is back? |
I will push the change later today. |
Hi @ihcsim,
On another context, by duplicate you mean the test cases are duplicate of the code that validates them. |
cc @Shrekster |
Not sure if I followed. We added a test case to validate a blueprint containing one function with default version and one function with non-default version. Why can't we test with one function of different versions? I am not suggesting we validate differences between two versions of the same function. Are you saying this is not a valid usage pattern 👇 ? func init() {
_ = kanister.RegisterVersion(&myTestFunc{}, nonDefaultFuncVersion)
_ = kanister.RegisterVersion(&myTestFunc{}, kanister.DefaultVersion)
}
Can you link to the code that does this? |
so its not invalid but we don't have the examples as of now. And even if we were doing that, the main thing is we don't validate a blueprint against different function versions. We just pass one version while validating a blueprint and if a function is not available in version we fallback to default function version. |
Talked to @ihcsim about this. |
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.
@viveksinghggits Thanks for the discussion. To limit the scope of this PR, it makes sense to separate the original validation test from the new version-related validation.
I think at one point, we might have to re-visit the support for multi-versions Kanister Function scenario.
I agree. |
Change Overview
This PR adds test for blueprint validation logic for the functions that are not registered with default function version.
Pull request type
Please check the type of change your PR introduces:
Issues
Test Plan