-
Notifications
You must be signed in to change notification settings - Fork 566
OCPBUGS-100301: fix(hostedcluster): handle Unknown status in ClusterVersionFailing inversion #9186
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3995,6 +3995,47 @@ func TestIsProgressing(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| func TestInvertConditionStatus(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| testCases := []struct { | ||
| name string | ||
| input metav1.ConditionStatus | ||
| expectedStatus metav1.ConditionStatus | ||
| }{ | ||
| { | ||
| name: "When status is True it should invert to False", | ||
| input: metav1.ConditionTrue, | ||
| expectedStatus: metav1.ConditionFalse, | ||
| }, | ||
| { | ||
| name: "When status is False it should invert to True", | ||
| input: metav1.ConditionFalse, | ||
| expectedStatus: metav1.ConditionTrue, | ||
| }, | ||
| { | ||
| name: "When status is Unknown it should produce Unknown", | ||
| input: metav1.ConditionUnknown, | ||
| expectedStatus: metav1.ConditionUnknown, | ||
| }, | ||
| { | ||
| name: "When status is empty string it should produce Unknown", | ||
| input: metav1.ConditionStatus(""), | ||
| expectedStatus: metav1.ConditionUnknown, | ||
| }, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Consider adding a fourth test case for {
name: "When ClusterVersionFailing has empty status it should produce ClusterVersionSucceeding Unknown",
hcpStatus: metav1.ConditionStatus(""),
expectedStatus: metav1.ConditionUnknown,
}, |
||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| g := NewWithT(t) | ||
|
Comment on lines
+4029
to
+4031
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The subtests should call t.Run(tc.name, func(t *testing.T) {
t.Parallel()
g := NewWithT(t) |
||
| result := invertConditionStatus(tc.input) | ||
| g.Expect(result).To(Equal(tc.expectedStatus)) | ||
| g.Expect(result).ToNot(BeEmpty(), "Status must not be empty string — API server rejects it") | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestComputeAWSDefaultSGDeletedCondition(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
|
|
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Cover unexpected statuses beyond
ConditionUnknown.The new fallback handles every status other than
TrueandFalse, but the table only tests the namedUnknownconstant. Add a case such asmetav1.ConditionStatus("Unexpected")and expectmetav1.ConditionUnknown.As per coding guidelines, unit test any code changes and additions.
🤖 Prompt for AI Agents
Source: Coding guidelines