@@ -44,9 +44,12 @@ func TestCopyToNamespace(t *testing.T) {
4444 Name : "copy created if does not exist" ,
4545 FromNamespace : "from" ,
4646 ToNamespace : "to" ,
47+ Hash : "hn-1" ,
48+ StatusHash : "hs" ,
4749 Prototype : v1alpha1.ClusterServiceVersion {
4850 ObjectMeta : metav1.ObjectMeta {
4951 Name : "name" ,
52+ Annotations : map [string ]string {},
5053 },
5154 Spec : v1alpha1.ClusterServiceVersionSpec {
5255 Replaces : "replacee" ,
@@ -60,6 +63,9 @@ func TestCopyToNamespace(t *testing.T) {
6063 ObjectMeta : metav1.ObjectMeta {
6164 Name : "name" ,
6265 Namespace : "to" ,
66+ Annotations : map [string ]string {
67+ nonStatusCopyHashAnnotation : "hn-1" ,
68+ },
6369 },
6470 Spec : v1alpha1.ClusterServiceVersionSpec {
6571 Replaces : "replacee" ,
@@ -80,6 +86,13 @@ func TestCopyToNamespace(t *testing.T) {
8086 Phase : "waxing gibbous" ,
8187 },
8288 }),
89+ ktesting .NewUpdateAction (gvr , "to" , & v1alpha1.ClusterServiceVersion {
90+ ObjectMeta : metav1.ObjectMeta {
91+ Annotations : map [string ]string {
92+ statusCopyHashAnnotation : "hs" ,
93+ },
94+ },
95+ })
8396 },
8497 ExpectedResult : & v1alpha1.ClusterServiceVersion {
8598 ObjectMeta : metav1.ObjectMeta {
@@ -97,6 +110,7 @@ func TestCopyToNamespace(t *testing.T) {
97110 Prototype : v1alpha1.ClusterServiceVersion {
98111 ObjectMeta : metav1.ObjectMeta {
99112 Name : "name" ,
113+ Annotations : map [string ]string {},
100114 },
101115 Spec : v1alpha1.ClusterServiceVersionSpec {
102116 Replaces : "replacee" ,
@@ -150,6 +164,7 @@ func TestCopyToNamespace(t *testing.T) {
150164 Prototype : v1alpha1.ClusterServiceVersion {
151165 ObjectMeta : metav1.ObjectMeta {
152166 Name : "name" ,
167+ Annotations : map [string ]string {},
153168 },
154169 Spec : v1alpha1.ClusterServiceVersionSpec {
155170 Replaces : "replacee" ,
@@ -203,6 +218,7 @@ func TestCopyToNamespace(t *testing.T) {
203218 Prototype : v1alpha1.ClusterServiceVersion {
204219 ObjectMeta : metav1.ObjectMeta {
205220 Name : "name" ,
221+ Annotations : map [string ]string {},
206222 },
207223 Spec : v1alpha1.ClusterServiceVersionSpec {
208224 Replaces : "replacee" ,
@@ -270,6 +286,7 @@ func TestCopyToNamespace(t *testing.T) {
270286 Prototype : v1alpha1.ClusterServiceVersion {
271287 ObjectMeta : metav1.ObjectMeta {
272288 Name : "name" ,
289+ Annotations : map [string ]string {},
273290 },
274291 },
275292 ExistingCopy : & metav1.PartialObjectMetadata {
@@ -311,10 +328,15 @@ func TestCopyToNamespace(t *testing.T) {
311328 logger : logger ,
312329 }
313330
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 )
315333
316334 if tc .ExpectedError == nil {
317335 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 ])
318340 } else {
319341 require .EqualError (t , err , tc .ExpectedError .Error ())
320342 }
0 commit comments