@@ -33,12 +33,12 @@ var (
33
33
falseWarning1 = FalseCondition ("falseWarning1" , "reason falseWarning1" , clusterv1 .ConditionSeverityWarning , "message falseWarning1" )
34
34
falseError1 = FalseCondition ("falseError1" , "reason falseError1" , clusterv1 .ConditionSeverityError , "message falseError1" )
35
35
36
- negativePolarityConditions = sets .New ("positive- false1" , "negative-unknown1 " , "negative-trueInfo1 " , "negative-trueWarning1 " , "negative-trueError1 " )
37
- positiveFalse1 = PositiveFalseCondition ( "positive- false1" )
38
- negativeUnknown1 = UnknownCondition ("negative-unknown1 " , "reason negative-unknown1 " , "message negative-unknown1 " )
39
- negativeTrueInfo1 = NegativeTrueCondition ( " negative-trueInfo1 " , "reason negative-trueInfo1 " , clusterv1 .ConditionSeverityInfo , "message negative-trueInfo1 " )
40
- negativeTrueWarning1 = NegativeTrueCondition ( " negative-trueWarning1 " , "reason negative-trueWarning1 " , clusterv1 .ConditionSeverityWarning , "message negative-trueWarning1 " )
41
- negativeTrueError1 = NegativeTrueCondition ( " negative-trueError1 " , "reason negative-trueError1 " , clusterv1 .ConditionSeverityError , "message negative-trueError1 " )
36
+ negativePolarityConditions = sets .New ("false1-negative-polarity " , "unknown1- negative-polarity " , "trueInfo1- negative-polarity " , "trueWarning1- negative-polarity " , "trueError1- negative-polarity " )
37
+ false1WithNegativePolarity = FalseConditionWithNegativePolarity ( " false1-negative-polarity " )
38
+ unknown1WithNegativePolarity = UnknownCondition ("unknown1- negative-polarity " , "reason unknown1- negative-polarity " , "message unknown1- negative-polarity " )
39
+ trueInfo1WithNegativePolarity = TrueConditionWithNegativePolarity ( "trueInfo1- negative-polarity " , "reason trueInfo1- negative-polarity " , clusterv1 .ConditionSeverityInfo , "message trueInfo1- negative-polarity " )
40
+ trueWarning1WithNegativePolarity = TrueConditionWithNegativePolarity ( "trueWarning1- negative-polarity " , "reason trueWarning1- negative-polarity " , clusterv1 .ConditionSeverityWarning , "message trueWarning1- negative-polarity " )
41
+ trueError1WithNegativePolarity = TrueConditionWithNegativePolarity ( "trueError1- negative-polarity " , "reason trueError1- negative-polarity " , clusterv1 .ConditionSeverityError , "message trueError1- negative-polarity " )
42
42
)
43
43
44
44
func TestGetAndHas (t * testing.T ) {
@@ -58,51 +58,51 @@ func TestGetAndHas(t *testing.T) {
58
58
func TestIsMethods (t * testing.T ) {
59
59
g := NewWithT (t )
60
60
61
- obj := getterWithConditions (nil1 , true1 , unknown1 , falseInfo1 , falseWarning1 , falseError1 , positiveFalse1 , negativeUnknown1 , negativeTrueInfo1 , negativeTrueWarning1 , negativeTrueError1 )
61
+ obj := getterWithConditions (nil1 , true1 , unknown1 , falseInfo1 , falseWarning1 , falseError1 , false1WithNegativePolarity , unknown1WithNegativePolarity , trueInfo1WithNegativePolarity , trueWarning1WithNegativePolarity , trueError1WithNegativePolarity )
62
62
63
63
// test isTrue
64
64
g .Expect (IsTrue (obj , "nil1" )).To (BeFalse ())
65
65
g .Expect (IsTrue (obj , "true1" )).To (BeTrue ())
66
66
g .Expect (IsTrue (obj , "falseInfo1" )).To (BeFalse ())
67
67
g .Expect (IsTrue (obj , "unknown1" )).To (BeFalse ())
68
- g .Expect (IsTrue (obj , "positive- false1" )).To (BeFalse ())
69
- g .Expect (IsTrue (obj , "negative-trueInfo1 " )).To (BeTrue ())
70
- g .Expect (IsTrue (obj , "negative-unknown1 " )).To (BeFalse ())
68
+ g .Expect (IsTrue (obj , "false1-negative-polarity " )).To (BeFalse ())
69
+ g .Expect (IsTrue (obj , "trueInfo1- negative-polarity " )).To (BeTrue ())
70
+ g .Expect (IsTrue (obj , "unknown1- negative-polarity " )).To (BeFalse ())
71
71
72
72
// test isFalse
73
73
g .Expect (IsFalse (obj , "nil1" )).To (BeFalse ())
74
74
g .Expect (IsFalse (obj , "true1" )).To (BeFalse ())
75
75
g .Expect (IsFalse (obj , "falseInfo1" )).To (BeTrue ())
76
76
g .Expect (IsFalse (obj , "unknown1" )).To (BeFalse ())
77
- g .Expect (IsFalse (obj , "positive- false1" )).To (BeTrue ())
78
- g .Expect (IsFalse (obj , "negative-trueInfo1 " )).To (BeFalse ())
79
- g .Expect (IsFalse (obj , "negative-unknown1 " )).To (BeFalse ())
77
+ g .Expect (IsFalse (obj , "false1-negative-polarity " )).To (BeTrue ())
78
+ g .Expect (IsFalse (obj , "trueInfo1- negative-polarity " )).To (BeFalse ())
79
+ g .Expect (IsFalse (obj , "unknown1- negative-polarity " )).To (BeFalse ())
80
80
81
81
// test isUnknown
82
82
g .Expect (IsUnknown (obj , "nil1" )).To (BeTrue ())
83
83
g .Expect (IsUnknown (obj , "true1" )).To (BeFalse ())
84
84
g .Expect (IsUnknown (obj , "falseInfo1" )).To (BeFalse ())
85
85
g .Expect (IsUnknown (obj , "unknown1" )).To (BeTrue ())
86
- g .Expect (IsUnknown (obj , "positive- false1" )).To (BeFalse ())
87
- g .Expect (IsUnknown (obj , "negative-trueInfo1 " )).To (BeFalse ())
88
- g .Expect (IsUnknown (obj , "negative-unknown1 " )).To (BeTrue ())
86
+ g .Expect (IsUnknown (obj , "false1-negative-polarity " )).To (BeFalse ())
87
+ g .Expect (IsUnknown (obj , "trueInfo1- negative-polarity " )).To (BeFalse ())
88
+ g .Expect (IsUnknown (obj , "unknown1- negative-polarity " )).To (BeTrue ())
89
89
90
90
// test GetReason
91
91
g .Expect (GetReason (obj , "nil1" )).To (Equal ("" ))
92
92
g .Expect (GetReason (obj , "falseInfo1" )).To (Equal ("reason falseInfo1" ))
93
- g .Expect (GetReason (obj , "negative-trueInfo1 " )).To (Equal ("reason negative-trueInfo1 " ))
93
+ g .Expect (GetReason (obj , "trueInfo1- negative-polarity " )).To (Equal ("reason trueInfo1- negative-polarity " ))
94
94
95
95
// test GetMessage
96
96
g .Expect (GetMessage (obj , "nil1" )).To (Equal ("" ))
97
97
g .Expect (GetMessage (obj , "falseInfo1" )).To (Equal ("message falseInfo1" ))
98
- g .Expect (GetMessage (obj , "negative-trueInfo1 " )).To (Equal ("message negative-trueInfo1 " ))
98
+ g .Expect (GetMessage (obj , "trueInfo1- negative-polarity " )).To (Equal ("message trueInfo1- negative-polarity " ))
99
99
100
100
// test GetSeverity
101
101
expectedSeverity := clusterv1 .ConditionSeverityInfo
102
102
g .Expect (GetSeverity (obj , "nil1" )).To (BeNil ())
103
103
severity := GetSeverity (obj , "falseInfo1" )
104
104
g .Expect (severity ).To (Equal (& expectedSeverity ))
105
- severity = GetSeverity (obj , "negative-trueInfo1 " )
105
+ severity = GetSeverity (obj , "trueInfo1- negative-polarity " )
106
106
g .Expect (severity ).To (Equal (& expectedSeverity ))
107
107
108
108
// test GetLastTransitionTime
@@ -153,8 +153,8 @@ func TestSummary(t *testing.T) {
153
153
foo := TrueCondition ("foo" )
154
154
bar := FalseCondition ("bar" , "reason falseInfo1" , clusterv1 .ConditionSeverityInfo , "message falseInfo1" )
155
155
baz := FalseCondition ("baz" , "reason falseInfo2" , clusterv1 .ConditionSeverityInfo , "message falseInfo2" )
156
- negativeFoo := PositiveFalseCondition ( " negative-foo " )
157
- negativeBar := NegativeTrueCondition ( " negative-bar " , "reason negative-falseInfo1 " , clusterv1 .ConditionSeverityInfo , "message negative-falseInfo1 " )
156
+ fooWithNegativePolarity := FalseConditionWithNegativePolarity ( "foo- negative-polarity " )
157
+ barWithNegativePolarity := TrueConditionWithNegativePolarity ( "bar- negative-polarity " , "reason trueInfo1- negative-polarity " , clusterv1 .ConditionSeverityInfo , "message trueInfo1- negative-polarity " )
158
158
existingReady := FalseCondition (clusterv1 .ReadyCondition , "reason falseError1" , clusterv1 .ConditionSeverityError , "message falseError1" ) // NB. existing ready has higher priority than other conditions
159
159
160
160
tests := []struct {
@@ -175,15 +175,15 @@ func TestSummary(t *testing.T) {
175
175
},
176
176
{
177
177
name : "Returns ready condition with the summary of existing conditions with negative polarity (with default options)" ,
178
- from : getterWithConditions (negativeFoo , negativeBar ),
179
- options : []MergeOption {WithNegativePolarityConditions ("negative-foo " , "negative-bar " )},
180
- want : FalseCondition (clusterv1 .ReadyCondition , "reason negative-falseInfo1 " , clusterv1 .ConditionSeverityInfo , "message negative-falseInfo1 " ),
178
+ from : getterWithConditions (fooWithNegativePolarity , barWithNegativePolarity ),
179
+ options : []MergeOption {WithNegativePolarityConditions ("foo- negative-polarity " , "bar- negative-polarity " )},
180
+ want : FalseCondition (clusterv1 .ReadyCondition , "reason trueInfo1- negative-polarity " , clusterv1 .ConditionSeverityInfo , "message trueInfo1- negative-polarity " ),
181
181
},
182
182
{
183
183
name : "Returns ready condition with the summary of existing conditions with mixed polarity (with default options)" ,
184
- from : getterWithConditions (foo , bar , negativeFoo , negativeBar ),
185
- options : []MergeOption {WithNegativePolarityConditions ("negative-foo " , "negative-bar " )},
186
- want : FalseCondition (clusterv1 .ReadyCondition , "reason falseInfo1" , clusterv1 .ConditionSeverityInfo , "message falseInfo1" ), // bar take precedence on negativeBar because it is listed first
184
+ from : getterWithConditions (foo , bar , fooWithNegativePolarity , barWithNegativePolarity ),
185
+ options : []MergeOption {WithNegativePolarityConditions ("foo- negative-polarity " , "bar- negative-polarity " )},
186
+ want : FalseCondition (clusterv1 .ReadyCondition , "reason falseInfo1" , clusterv1 .ConditionSeverityInfo , "message falseInfo1" ), // bar take precedence on barWithNegativePolarity because it is listed first
187
187
},
188
188
{
189
189
name : "Returns ready condition with the summary of existing conditions (using WithStepCounter options)" ,
@@ -223,15 +223,15 @@ func TestSummary(t *testing.T) {
223
223
},
224
224
{
225
225
name : "Returns ready condition with the summary of selected conditions with negative polarity (using WithConditions options)" ,
226
- from : getterWithConditions (negativeFoo , negativeBar ),
227
- options : []MergeOption {WithConditions ("negative-foo " ), WithNegativePolarityConditions ("negative-foo " , "negative-bar " )}, // negative-bar should be ignored
226
+ from : getterWithConditions (fooWithNegativePolarity , barWithNegativePolarity ),
227
+ options : []MergeOption {WithConditions ("foo- negative-polarity " ), WithNegativePolarityConditions ("foo- negative-polarity " , "bar- negative-polarity " )}, // bar- negative-polarity should be ignored because it is not listed in WithConditions
228
228
want : TrueCondition (clusterv1 .ReadyCondition ),
229
229
},
230
230
{
231
231
name : "Returns ready condition with the summary of selected conditions with mixed polarity (using WithConditions options)" ,
232
- from : getterWithConditions (foo , bar , negativeFoo , negativeBar ),
233
- options : []MergeOption {WithConditions ("foo" , "negative-foo " , "negative-bar " ), WithNegativePolarityConditions ("negative-foo " , "negative-bar " )}, // bar should be ignored
234
- want : FalseCondition (clusterv1 .ReadyCondition , "reason negative-falseInfo1 " , clusterv1 .ConditionSeverityInfo , "message negative-falseInfo1 " ),
232
+ from : getterWithConditions (foo , bar , fooWithNegativePolarity , barWithNegativePolarity ),
233
+ options : []MergeOption {WithConditions ("foo" , "foo- negative-polarity " , "bar- negative-polarity " ), WithNegativePolarityConditions ("foo- negative-polarity " , "bar- negative-polarity " )},
234
+ want : FalseCondition (clusterv1 .ReadyCondition , "reason trueInfo1- negative-polarity " , clusterv1 .ConditionSeverityInfo , "message trueInfo1- negative-polarity " ),
235
235
},
236
236
{
237
237
name : "Returns ready condition with the summary of selected conditions (using WithConditions and WithStepCounter options)" ,
0 commit comments