9
9
"github.com/stretchr/testify/assert"
10
10
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11
11
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
12
+
13
+ carenv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
12
14
)
13
15
14
16
func TestNew (t * testing.T ) {
@@ -37,14 +39,14 @@ func TestNew(t *testing.T) {
37
39
{
38
40
name : "ignores empty skip annotation value" ,
39
41
annotations : map [string ]string {
40
- AnnotationKey : "" ,
42
+ carenv1 . PreflightChecksSkipAnnotationKey : "" ,
41
43
},
42
44
expectCheckNames : map [string ]struct {}{},
43
45
},
44
46
{
45
47
name : "ignores empty check names" ,
46
48
annotations : map [string ]string {
47
- AnnotationKey : "InfraVMImage,,InfraCredentials," ,
49
+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraVMImage,,InfraCredentials," ,
48
50
},
49
51
expectCheckNames : map [string ]struct {}{
50
52
"infravmimage" : {},
@@ -54,14 +56,14 @@ func TestNew(t *testing.T) {
54
56
{
55
57
name : "ignores value of only commas" ,
56
58
annotations : map [string ]string {
57
- AnnotationKey : ",,," ,
59
+ carenv1 . PreflightChecksSkipAnnotationKey : ",,," ,
58
60
},
59
61
expectCheckNames : map [string ]struct {}{},
60
62
},
61
63
{
62
64
name : "accepts single check name" ,
63
65
annotations : map [string ]string {
64
- AnnotationKey : "InfraVMImage" ,
66
+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraVMImage" ,
65
67
},
66
68
expectCheckNames : map [string ]struct {}{
67
69
"infravmimage" : {},
@@ -70,7 +72,7 @@ func TestNew(t *testing.T) {
70
72
{
71
73
name : "accepts multiple check names" ,
72
74
annotations : map [string ]string {
73
- AnnotationKey : "InfraVMImage,InfraCredentials" ,
75
+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraVMImage,InfraCredentials" ,
74
76
},
75
77
expectCheckNames : map [string ]struct {}{
76
78
"infravmimage" : {},
@@ -80,7 +82,7 @@ func TestNew(t *testing.T) {
80
82
{
81
83
name : "trims spaces from check names" ,
82
84
annotations : map [string ]string {
83
- AnnotationKey : " InfraVMImage , InfraCredentials " ,
85
+ carenv1 . PreflightChecksSkipAnnotationKey : " InfraVMImage , InfraCredentials " ,
84
86
},
85
87
expectCheckNames : map [string ]struct {}{
86
88
"infravmimage" : {},
@@ -125,47 +127,47 @@ func TestEvaluator_For(t *testing.T) {
125
127
{
126
128
name : "empty annotation value" ,
127
129
annotations : map [string ]string {
128
- AnnotationKey : "" ,
130
+ carenv1 . PreflightChecksSkipAnnotationKey : "" ,
129
131
},
130
132
checkName : "InfraVMImage" ,
131
133
expectMatch : false ,
132
134
},
133
135
{
134
136
name : "skip InfraVMImage check" ,
135
137
annotations : map [string ]string {
136
- AnnotationKey : "InfraVMImage,InfraCredentials" ,
138
+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraVMImage,InfraCredentials" ,
137
139
},
138
140
checkName : "InfraVMImage" ,
139
141
expectMatch : true ,
140
142
},
141
143
{
142
144
name : "skip credentials, but not image" ,
143
145
annotations : map [string ]string {
144
- AnnotationKey : "InfraCredentials" ,
146
+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraCredentials" ,
145
147
},
146
148
checkName : "InfraVMImage" ,
147
149
expectMatch : false ,
148
150
},
149
151
{
150
152
name : "skip with spaces and case mixing" ,
151
153
annotations : map [string ]string {
152
- AnnotationKey : " infraVMImage , InfraCredentials " ,
154
+ carenv1 . PreflightChecksSkipAnnotationKey : " infraVMImage , InfraCredentials " ,
153
155
},
154
156
checkName : "InfraVMImage" ,
155
157
expectMatch : true ,
156
158
},
157
159
{
158
160
name : "extra commas do not affect matching" ,
159
161
annotations : map [string ]string {
160
- AnnotationKey : "InfraVMImage,,InfraCredentials," ,
162
+ carenv1 . PreflightChecksSkipAnnotationKey : "InfraVMImage,,InfraCredentials," ,
161
163
},
162
164
checkName : "InfraVMImage" ,
163
165
expectMatch : true ,
164
166
},
165
167
{
166
168
name : "skip all checks" ,
167
169
annotations : map [string ]string {
168
- AnnotationKey : "all" ,
170
+ carenv1 . PreflightChecksSkipAnnotationKey : "all" ,
169
171
},
170
172
checkName : "InfraVMImage" ,
171
173
expectMatch : true ,
@@ -206,34 +208,34 @@ func TestEvaluator_ForAll(t *testing.T) {
206
208
{
207
209
name : "empty annotation value" ,
208
210
annotations : map [string ]string {
209
- AnnotationKey : "" ,
211
+ carenv1 . PreflightChecksSkipAnnotationKey : "" ,
210
212
},
211
213
},
212
214
{
213
215
name : "skip all checks with spaces and case mixing" ,
214
216
annotations : map [string ]string {
215
- AnnotationKey : " aLL " ,
217
+ carenv1 . PreflightChecksSkipAnnotationKey : " aLL " ,
216
218
},
217
219
expectMatch : true ,
218
220
},
219
221
{
220
222
name : "skip all checks with extra commas" ,
221
223
annotations : map [string ]string {
222
- AnnotationKey : ",all,," ,
224
+ carenv1 . PreflightChecksSkipAnnotationKey : ",all,," ,
223
225
},
224
226
expectMatch : true ,
225
227
},
226
228
{
227
229
name : "skip all checks" ,
228
230
annotations : map [string ]string {
229
- AnnotationKey : "all" ,
231
+ carenv1 . PreflightChecksSkipAnnotationKey : "all" ,
230
232
},
231
233
expectMatch : true ,
232
234
},
233
235
{
234
236
name : "skip some checks, but not all" ,
235
237
annotations : map [string ]string {
236
- AnnotationKey : "OneCheck,AnotherCheck" ,
238
+ carenv1 . PreflightChecksSkipAnnotationKey : "OneCheck,AnotherCheck" ,
237
239
},
238
240
expectMatch : false ,
239
241
},
0 commit comments