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