@@ -10,165 +10,21 @@ import (
10
10
)
11
11
12
12
func TestNoBetterThan (t * testing.T ) {
13
- type args struct {
14
- css CommitStatusState
15
- css2 CommitStatusState
16
- }
17
- var unExpectedState CommitStatusState
18
13
tests := []struct {
19
- name string
20
- args args
21
- want bool
14
+ s1 , s2 CommitStatusState
15
+ higher bool
22
16
}{
23
- {
24
- name : "success is no better than success" ,
25
- args : args {
26
- css : CommitStatusSuccess ,
27
- css2 : CommitStatusSuccess ,
28
- },
29
- want : true ,
30
- },
31
- {
32
- name : "success is no better than pending" ,
33
- args : args {
34
- css : CommitStatusSuccess ,
35
- css2 : CommitStatusPending ,
36
- },
37
- want : false ,
38
- },
39
- {
40
- name : "success is no better than failure" ,
41
- args : args {
42
- css : CommitStatusSuccess ,
43
- css2 : CommitStatusFailure ,
44
- },
45
- want : false ,
46
- },
47
- {
48
- name : "success is no better than error" ,
49
- args : args {
50
- css : CommitStatusSuccess ,
51
- css2 : CommitStatusError ,
52
- },
53
- want : false ,
54
- },
55
- {
56
- name : "pending is no better than success" ,
57
- args : args {
58
- css : CommitStatusPending ,
59
- css2 : CommitStatusSuccess ,
60
- },
61
- want : true ,
62
- },
63
- {
64
- name : "pending is no better than pending" ,
65
- args : args {
66
- css : CommitStatusPending ,
67
- css2 : CommitStatusPending ,
68
- },
69
- want : true ,
70
- },
71
- {
72
- name : "pending is no better than failure" ,
73
- args : args {
74
- css : CommitStatusPending ,
75
- css2 : CommitStatusFailure ,
76
- },
77
- want : false ,
78
- },
79
- {
80
- name : "pending is no better than error" ,
81
- args : args {
82
- css : CommitStatusPending ,
83
- css2 : CommitStatusError ,
84
- },
85
- want : false ,
86
- },
87
- {
88
- name : "failure is no better than success" ,
89
- args : args {
90
- css : CommitStatusFailure ,
91
- css2 : CommitStatusSuccess ,
92
- },
93
- want : true ,
94
- },
95
- {
96
- name : "failure is no better than pending" ,
97
- args : args {
98
- css : CommitStatusFailure ,
99
- css2 : CommitStatusPending ,
100
- },
101
- want : true ,
102
- },
103
- {
104
- name : "failure is no better than failure" ,
105
- args : args {
106
- css : CommitStatusFailure ,
107
- css2 : CommitStatusFailure ,
108
- },
109
- want : true ,
110
- },
111
- {
112
- name : "failure is no better than error" ,
113
- args : args {
114
- css : CommitStatusFailure ,
115
- css2 : CommitStatusError ,
116
- },
117
- want : false ,
118
- },
119
- {
120
- name : "error is no better than success" ,
121
- args : args {
122
- css : CommitStatusError ,
123
- css2 : CommitStatusSuccess ,
124
- },
125
- want : true ,
126
- },
127
- {
128
- name : "error is no better than pending" ,
129
- args : args {
130
- css : CommitStatusError ,
131
- css2 : CommitStatusPending ,
132
- },
133
- want : true ,
134
- },
135
- {
136
- name : "error is no better than failure" ,
137
- args : args {
138
- css : CommitStatusError ,
139
- css2 : CommitStatusFailure ,
140
- },
141
- want : true ,
142
- },
143
- {
144
- name : "error is no better than error" ,
145
- args : args {
146
- css : CommitStatusError ,
147
- css2 : CommitStatusError ,
148
- },
149
- want : true ,
150
- },
151
- {
152
- name : "unExpectedState is no better than success" ,
153
- args : args {
154
- css : unExpectedState ,
155
- css2 : CommitStatusSuccess ,
156
- },
157
- want : false ,
158
- },
159
- {
160
- name : "unExpectedState is no better than unExpectedState" ,
161
- args : args {
162
- css : unExpectedState ,
163
- css2 : unExpectedState ,
164
- },
165
- want : false ,
166
- },
17
+ {CommitStatusError , CommitStatusFailure , true },
18
+ {CommitStatusFailure , CommitStatusWarning , true },
19
+ {CommitStatusWarning , CommitStatusPending , true },
20
+ {CommitStatusPending , CommitStatusSuccess , true },
21
+ {CommitStatusSuccess , CommitStatusSkipped , true },
22
+
23
+ {CommitStatusError , "unknown-xxx" , false },
24
+ {"unknown-xxx" , CommitStatusFailure , true },
167
25
}
168
26
for _ , tt := range tests {
169
- t .Run (tt .name , func (t * testing.T ) {
170
- result := tt .args .css .NoBetterThan (tt .args .css2 )
171
- assert .Equal (t , tt .want , result )
172
- })
27
+ assert .Equal (t , tt .higher , tt .s1 .HasHigherPriorityThan (tt .s2 ), "s1=%s, s2=%s, expected=%v" , tt .s1 , tt .s2 , tt .higher )
173
28
}
29
+ assert .False (t , CommitStatusError .HasHigherPriorityThan (CommitStatusError ))
174
30
}
0 commit comments