-
Notifications
You must be signed in to change notification settings - Fork 22
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 utility functions to support tests on SpaceProvisionerConfig.Status.ConsumedCapacity #434
Add utility functions to support tests on SpaceProvisionerConfig.Status.ConsumedCapacity #434
Conversation
Quality Gate passedIssues Measures |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #434 +/- ##
=======================================
Coverage 78.23% 78.23%
=======================================
Files 49 49
Lines 2444 2444
=======================================
Hits 1912 1912
Misses 478 478
Partials 54 54 |
cond, found := condition.FindConditionByType(spc.Status.Conditions, toolchainv1alpha1.ConditionReady) | ||
if !found { | ||
return false | ||
} | ||
|
||
func (*ready) FixToMatch(spc *toolchainv1alpha1.SpaceProvisionerConfig) *toolchainv1alpha1.SpaceProvisionerConfig { | ||
spc.Status.Conditions, _ = condition.AddOrUpdateStatusConditions(spc.Status.Conditions, toolchainv1alpha1.Condition{ | ||
Type: toolchainv1alpha1.ConditionReady, | ||
Status: corev1.ConditionTrue, | ||
Reason: toolchainv1alpha1.SpaceProvisionerConfigValidReason, | ||
}) | ||
return spc | ||
} | ||
if cond.Status != r.expectedStatus { | ||
return false | ||
} | ||
|
||
func Ready() assertions.Predicate[*toolchainv1alpha1.SpaceProvisionerConfig] { | ||
return &ready{} | ||
} | ||
if r.expectedReason != nil && cond.Reason != *r.expectedReason { | ||
return false | ||
} | ||
|
||
func (*notReady) Matches(spc *toolchainv1alpha1.SpaceProvisionerConfig) bool { | ||
return condition.IsFalse(spc.Status.Conditions, toolchainv1alpha1.ConditionReady) | ||
return true |
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.
why not using ConditionsMatch
or ContainsCondition
from the test
package
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.
The main reason is that this struct is reused in a couple of predicate functions, e.g. func NotReady()
returns a predictate that tests only for the readiness status of the ready condition regardless of the reason, which is not expressible using ConditionsMatch
or ContainsCondition
.
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.
please, consider using the already existing functions related to conditions available in the repo #434 (comment)
This just adds a couple of utility functions and predicates to be used by the tests on the new
SpaceProvisionerConfig.Status.ConsumedCapacity
. The functions will be used in code in the host operator and e2e tests in the upcoming PRs.