Skip to content

Commit c79c7d3

Browse files
authored
Merge pull request #9015 from Dhairya-Arora01/BeComparable
🌱 Replacing gomega.Equal with gomega.BeComparableTo
2 parents e59efac + dc65096 commit c79c7d3

File tree

81 files changed

+212
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+212
-212
lines changed

bootstrap/kubeadm/api/v1alpha4/kubeadm_types_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestUnmarshalJSON(t *testing.T) {
7171
} else {
7272
g.Expect(err).ToNot(HaveOccurred())
7373
}
74-
g.Expect(newbts).To(Equal(rt.bts))
74+
g.Expect(newbts).To(BeComparableTo(rt.bts))
7575
})
7676
}
7777
}
@@ -182,7 +182,7 @@ func TestNewBootstrapTokenString(t *testing.T) {
182182
} else {
183183
g.Expect(err).ToNot(HaveOccurred())
184184
}
185-
g.Expect(actual).To(Equal(rt.bts))
185+
g.Expect(actual).To(BeComparableTo(rt.bts))
186186
})
187187
}
188188
}

bootstrap/kubeadm/api/v1beta1/kubeadm_types_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestBootstrapTokenStringUnmarshalJSON(t *testing.T) {
129129
} else {
130130
g.Expect(err).ToNot(HaveOccurred())
131131
}
132-
g.Expect(newbts).To(Equal(rt.bts))
132+
g.Expect(newbts).To(BeComparableTo(rt.bts))
133133
})
134134
}
135135
}
@@ -240,7 +240,7 @@ func TestNewBootstrapTokenString(t *testing.T) {
240240
} else {
241241
g.Expect(err).ToNot(HaveOccurred())
242242
}
243-
g.Expect(actual).To(Equal(rt.bts))
243+
g.Expect(actual).To(BeComparableTo(rt.bts))
244244
})
245245
}
246246
}

bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ func TestKubeadmConfigReconciler_ReturnEarlyIfClusterInfraNotReady(t *testing.T)
338338

339339
expectedResult := reconcile.Result{}
340340
actualResult, actualError := k.Reconcile(ctx, request)
341-
g.Expect(actualResult).To(Equal(expectedResult))
341+
g.Expect(actualResult).To(BeComparableTo(expectedResult))
342342
g.Expect(actualError).ToNot(HaveOccurred())
343343
assertHasFalseCondition(g, myclient, request, bootstrapv1.DataSecretAvailableCondition, clusterv1.ConditionSeverityInfo, bootstrapv1.WaitingForClusterInfrastructureReason)
344344
}
@@ -1566,7 +1566,7 @@ func TestKubeadmConfigReconciler_Reconcile_DiscoveryReconcileFailureBehaviors(t
15661566
g := NewWithT(t)
15671567

15681568
res, err := k.reconcileDiscovery(ctx, tc.cluster, tc.config, secret.Certificates{})
1569-
g.Expect(res).To(Equal(tc.result))
1569+
g.Expect(res).To(BeComparableTo(tc.result))
15701570
if tc.err == nil {
15711571
g.Expect(err).ToNot(HaveOccurred())
15721572
} else {
@@ -2084,7 +2084,7 @@ func TestKubeadmConfigReconciler_ResolveFiles(t *testing.T) {
20842084

20852085
files, err := k.resolveFiles(ctx, tc.cfg)
20862086
g.Expect(err).ToNot(HaveOccurred())
2087-
g.Expect(files).To(Equal(tc.expect))
2087+
g.Expect(files).To(BeComparableTo(tc.expect))
20882088
for _, file := range tc.cfg.Spec.Files {
20892089
if contentFrom[file.Path] {
20902090
g.Expect(file.ContentFrom).NotTo(BeNil())
@@ -2211,7 +2211,7 @@ func TestKubeadmConfigReconciler_ResolveUsers(t *testing.T) {
22112211

22122212
users, err := k.resolveUsers(ctx, tc.cfg)
22132213
g.Expect(err).ToNot(HaveOccurred())
2214-
g.Expect(users).To(Equal(tc.expect))
2214+
g.Expect(users).To(BeComparableTo(tc.expect))
22152215
for _, user := range tc.cfg.Spec.Users {
22162216
if passwdFrom[user.Name] {
22172217
g.Expect(user.PasswdFrom).NotTo(BeNil())

bootstrap/kubeadm/types/upstreamv1beta1/bootstraptokenstring_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestUnmarshalJSON(t *testing.T) {
7171
} else {
7272
g.Expect(err).ToNot(HaveOccurred())
7373
}
74-
g.Expect(newbts).To(Equal(rt.bts))
74+
g.Expect(newbts).To(BeComparableTo(rt.bts))
7575
})
7676
}
7777
}
@@ -182,7 +182,7 @@ func TestNewBootstrapTokenString(t *testing.T) {
182182
} else {
183183
g.Expect(err).ToNot(HaveOccurred())
184184
}
185-
g.Expect(actual).To(Equal(rt.bts))
185+
g.Expect(actual).To(BeComparableTo(rt.bts))
186186
})
187187
}
188188
}
@@ -217,7 +217,7 @@ func TestNewBootstrapTokenStringFromIDAndSecret(t *testing.T) {
217217
} else {
218218
g.Expect(err).ToNot(HaveOccurred())
219219
}
220-
g.Expect(actual).To(Equal(rt.bts))
220+
g.Expect(actual).To(BeComparableTo(rt.bts))
221221
})
222222
}
223223
}

bootstrap/kubeadm/types/upstreamv1beta2/bootstraptokenstring_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestUnmarshalJSON(t *testing.T) {
7171
} else {
7272
g.Expect(err).ToNot(HaveOccurred())
7373
}
74-
g.Expect(newbts).To(Equal(rt.bts))
74+
g.Expect(newbts).To(BeComparableTo(rt.bts))
7575
})
7676
}
7777
}
@@ -182,7 +182,7 @@ func TestNewBootstrapTokenString(t *testing.T) {
182182
} else {
183183
g.Expect(err).ToNot(HaveOccurred())
184184
}
185-
g.Expect(actual).To(Equal(rt.bts))
185+
g.Expect(actual).To(BeComparableTo(rt.bts))
186186
})
187187
}
188188
}
@@ -217,7 +217,7 @@ func TestNewBootstrapTokenStringFromIDAndSecret(t *testing.T) {
217217
} else {
218218
g.Expect(err).ToNot(HaveOccurred())
219219
}
220-
g.Expect(actual).To(Equal(rt.bts))
220+
g.Expect(actual).To(BeComparableTo(rt.bts))
221221
})
222222
}
223223
}

bootstrap/kubeadm/types/utils_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func TestKubeVersionToKubeadmAPIGroupVersion(t *testing.T) {
139139
return
140140
}
141141
g.Expect(err).ToNot(HaveOccurred())
142-
g.Expect(got).To(Equal(tt.want))
142+
g.Expect(got).To(BeComparableTo(tt.want))
143143
})
144144
}
145145
}
@@ -496,7 +496,7 @@ func TestUnmarshalClusterConfiguration(t *testing.T) {
496496
return
497497
}
498498
g.Expect(err).ToNot(HaveOccurred())
499-
g.Expect(got).To(Equal(tt.want), cmp.Diff(tt.want, got))
499+
g.Expect(got).To(BeComparableTo(tt.want), cmp.Diff(tt.want, got))
500500
})
501501
}
502502
}
@@ -551,7 +551,7 @@ func TestUnmarshalClusterStatus(t *testing.T) {
551551
return
552552
}
553553
g.Expect(err).ToNot(HaveOccurred())
554-
g.Expect(got).To(Equal(tt.want), cmp.Diff(tt.want, got))
554+
g.Expect(got).To(BeComparableTo(tt.want), cmp.Diff(tt.want, got))
555555
})
556556
}
557557
}
@@ -610,7 +610,7 @@ func TestUnmarshalInitConfiguration(t *testing.T) {
610610
return
611611
}
612612
g.Expect(err).ToNot(HaveOccurred())
613-
g.Expect(got).To(Equal(tt.want), cmp.Diff(tt.want, got))
613+
g.Expect(got).To(BeComparableTo(tt.want), cmp.Diff(tt.want, got))
614614
})
615615
}
616616
}
@@ -669,7 +669,7 @@ func TestUnmarshalJoinConfiguration(t *testing.T) {
669669
return
670670
}
671671
g.Expect(err).ToNot(HaveOccurred())
672-
g.Expect(got).To(Equal(tt.want), cmp.Diff(tt.want, got))
672+
g.Expect(got).To(BeComparableTo(tt.want), cmp.Diff(tt.want, got))
673673
})
674674
}
675675
}

cmd/clusterctl/api/v1alpha3/metadata_type_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestGetReleaseSeriesForContract(t *testing.T) {
6565
g := NewWithT(t)
6666

6767
m := &Metadata{ReleaseSeries: test.releaseSeries}
68-
g.Expect(m.GetReleaseSeriesForContract(test.contract)).To(Equal(test.expectedReleaseSeries))
68+
g.Expect(m.GetReleaseSeriesForContract(test.contract)).To(BeComparableTo(test.expectedReleaseSeries))
6969
})
7070
}
7171
}

cmd/clusterctl/client/cluster/cert_manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ func Test_certManagerClient_PlanUpgrade(t *testing.T) {
715715
actualPlan, err := cm.PlanUpgrade()
716716
if tt.expectErr {
717717
g.Expect(err).To(HaveOccurred())
718-
g.Expect(actualPlan).To(Equal(CertManagerUpgradePlan{}))
718+
g.Expect(actualPlan).To(BeComparableTo(CertManagerUpgradePlan{}))
719719
return
720720
}
721721
g.Expect(err).ToNot(HaveOccurred())

cmd/clusterctl/client/cluster/mover_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ func Test_objectMover_restoreTargetObject(t *testing.T) {
912912
g.Expect(oAfter.GetName()).Should(Equal(oTo.GetName()))
913913
g.Expect(oAfter.GetCreationTimestamp()).Should(Equal(oTo.GetCreationTimestamp()))
914914
g.Expect(oAfter.GetUID()).Should(Equal(oTo.GetUID()))
915-
g.Expect(oAfter.GetOwnerReferences()).Should(Equal(oTo.GetOwnerReferences()))
915+
g.Expect(oAfter.GetOwnerReferences()).Should(BeComparableTo(oTo.GetOwnerReferences()))
916916
}
917917
})
918918
}

cmd/clusterctl/client/cluster/topology_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func Test_topologyClient_Plan(t *testing.T) {
300300
g.Expect(res.ReconciledCluster).To(BeNil())
301301
} else {
302302
g.Expect(res.ReconciledCluster).NotTo(BeNil())
303-
g.Expect(*res.ReconciledCluster).To(Equal(*tt.want.reconciledCluster))
303+
g.Expect(*res.ReconciledCluster).To(BeComparableTo(*tt.want.reconciledCluster))
304304
}
305305

306306
// Check the created objects.

0 commit comments

Comments
 (0)