@@ -41,7 +41,7 @@ import (
41
41
func TestMachineToInfrastructureMapFunc (t * testing.T ) {
42
42
g := NewWithT (t )
43
43
44
- var testcases = []struct {
44
+ testcases : = []struct {
45
45
name string
46
46
input schema.GroupVersionKind
47
47
request client.Object
@@ -110,7 +110,7 @@ func TestMachineToInfrastructureMapFunc(t *testing.T) {
110
110
}
111
111
112
112
func TestClusterToInfrastructureMapFunc (t * testing.T ) {
113
- var testcases = []struct {
113
+ testcases : = []struct {
114
114
name string
115
115
input schema.GroupVersionKind
116
116
request * clusterv1.Cluster
@@ -874,10 +874,15 @@ func TestRemoveOwnerRef(t *testing.T) {
874
874
},
875
875
},
876
876
}
877
+
878
+ originalOwnerRefs := append ([]metav1.OwnerReference {}, ownerRefs ... )
877
879
for _ , tt := range tests {
878
880
t .Run (tt .name , func (t * testing.T ) {
879
- newOwnerRefs := RemoveOwnerRef (ownerRefs , tt .toBeRemoved )
880
- g .Expect (HasOwnerRef (newOwnerRefs , tt .toBeRemoved )).NotTo (BeTrue ())
881
+ result := RemoveOwnerRef (ownerRefs , tt .toBeRemoved )
882
+ // RemoveOwnerRef should remove the owner ref, if it is found.
883
+ g .Expect (HasOwnerRef (result , tt .toBeRemoved )).NotTo (BeTrue ())
884
+ // RemoveOwnerRef should not mutate its input.
885
+ g .Expect (ownerRefs ).To (Equal (originalOwnerRefs ), "RemoveOwnerRef mutated its input" )
881
886
})
882
887
}
883
888
}
0 commit comments