@@ -46,9 +46,12 @@ func TestCopyToNamespace(t *testing.T) {
46
46
Name : "copy created if does not exist" ,
47
47
FromNamespace : "from" ,
48
48
ToNamespace : "to" ,
49
+ Hash : "hn-1" ,
50
+ StatusHash : "hs" ,
49
51
Prototype : v1alpha1.ClusterServiceVersion {
50
52
ObjectMeta : metav1.ObjectMeta {
51
53
Name : "name" ,
54
+ Annotations : map [string ]string {},
52
55
},
53
56
Spec : v1alpha1.ClusterServiceVersionSpec {
54
57
Replaces : "replacee" ,
@@ -62,6 +65,9 @@ func TestCopyToNamespace(t *testing.T) {
62
65
ObjectMeta : metav1.ObjectMeta {
63
66
Name : "name" ,
64
67
Namespace : "to" ,
68
+ Annotations : map [string ]string {
69
+ nonStatusCopyHashAnnotation : "hn-1" ,
70
+ },
65
71
},
66
72
Spec : v1alpha1.ClusterServiceVersionSpec {
67
73
Replaces : "replacee" ,
@@ -82,6 +88,13 @@ func TestCopyToNamespace(t *testing.T) {
82
88
Phase : "waxing gibbous" ,
83
89
},
84
90
}),
91
+ ktesting .NewUpdateAction (gvr , "to" , & v1alpha1.ClusterServiceVersion {
92
+ ObjectMeta : metav1.ObjectMeta {
93
+ Annotations : map [string ]string {
94
+ statusCopyHashAnnotation : "hs" ,
95
+ },
96
+ },
97
+ })
85
98
},
86
99
ExpectedResult : & v1alpha1.ClusterServiceVersion {
87
100
ObjectMeta : metav1.ObjectMeta {
@@ -99,6 +112,7 @@ func TestCopyToNamespace(t *testing.T) {
99
112
Prototype : v1alpha1.ClusterServiceVersion {
100
113
ObjectMeta : metav1.ObjectMeta {
101
114
Name : "name" ,
115
+ Annotations : map [string ]string {},
102
116
},
103
117
Spec : v1alpha1.ClusterServiceVersionSpec {
104
118
Replaces : "replacee" ,
@@ -152,6 +166,7 @@ func TestCopyToNamespace(t *testing.T) {
152
166
Prototype : v1alpha1.ClusterServiceVersion {
153
167
ObjectMeta : metav1.ObjectMeta {
154
168
Name : "name" ,
169
+ Annotations : map [string ]string {},
155
170
},
156
171
Spec : v1alpha1.ClusterServiceVersionSpec {
157
172
Replaces : "replacee" ,
@@ -205,6 +220,7 @@ func TestCopyToNamespace(t *testing.T) {
205
220
Prototype : v1alpha1.ClusterServiceVersion {
206
221
ObjectMeta : metav1.ObjectMeta {
207
222
Name : "name" ,
223
+ Annotations : map [string ]string {},
208
224
},
209
225
Spec : v1alpha1.ClusterServiceVersionSpec {
210
226
Replaces : "replacee" ,
@@ -272,6 +288,7 @@ func TestCopyToNamespace(t *testing.T) {
272
288
Prototype : v1alpha1.ClusterServiceVersion {
273
289
ObjectMeta : metav1.ObjectMeta {
274
290
Name : "name" ,
291
+ Annotations : map [string ]string {},
275
292
},
276
293
},
277
294
ExistingCopy : & metav1.PartialObjectMetadata {
@@ -313,10 +330,15 @@ func TestCopyToNamespace(t *testing.T) {
313
330
logger : logger ,
314
331
}
315
332
316
- result , err := o .copyToNamespace (tc .Prototype .DeepCopy (), tc .FromNamespace , tc .ToNamespace , tc .Hash , tc .StatusHash )
333
+ proto := tc .Prototype .DeepCopy ()
334
+ result , err := o .copyToNamespace (proto , tc .FromNamespace , tc .ToNamespace , tc .Hash , tc .StatusHash )
317
335
318
336
if tc .ExpectedError == nil {
319
337
require .NoError (t , err )
338
+ // if there is no error expected, ensure that the hash annotations are always present on the resulting CSV
339
+ annotations := proto .GetObjectMeta ().GetAnnotations ()
340
+ require .Equal (t , tc .Hash , annotations [nonStatusCopyHashAnnotation ])
341
+ require .Equal (t , tc .StatusHash , annotations [statusCopyHashAnnotation ])
320
342
} else {
321
343
require .EqualError (t , err , tc .ExpectedError .Error ())
322
344
}
0 commit comments