Skip to content

Commit

Permalink
Merge pull request #9015 from Dhairya-Arora01/BeComparable
Browse files Browse the repository at this point in the history
🌱 Replacing gomega.Equal with gomega.BeComparableTo
  • Loading branch information
k8s-ci-robot committed Aug 18, 2023
2 parents e59efac + dc65096 commit c79c7d3
Show file tree
Hide file tree
Showing 81 changed files with 212 additions and 212 deletions.
4 changes: 2 additions & 2 deletions bootstrap/kubeadm/api/v1alpha4/kubeadm_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestUnmarshalJSON(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(newbts).To(Equal(rt.bts))
g.Expect(newbts).To(BeComparableTo(rt.bts))
})
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestNewBootstrapTokenString(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(actual).To(Equal(rt.bts))
g.Expect(actual).To(BeComparableTo(rt.bts))
})
}
}
4 changes: 2 additions & 2 deletions bootstrap/kubeadm/api/v1beta1/kubeadm_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestBootstrapTokenStringUnmarshalJSON(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(newbts).To(Equal(rt.bts))
g.Expect(newbts).To(BeComparableTo(rt.bts))
})
}
}
Expand Down Expand Up @@ -240,7 +240,7 @@ func TestNewBootstrapTokenString(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(actual).To(Equal(rt.bts))
g.Expect(actual).To(BeComparableTo(rt.bts))
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func TestKubeadmConfigReconciler_ReturnEarlyIfClusterInfraNotReady(t *testing.T)

expectedResult := reconcile.Result{}
actualResult, actualError := k.Reconcile(ctx, request)
g.Expect(actualResult).To(Equal(expectedResult))
g.Expect(actualResult).To(BeComparableTo(expectedResult))
g.Expect(actualError).ToNot(HaveOccurred())
assertHasFalseCondition(g, myclient, request, bootstrapv1.DataSecretAvailableCondition, clusterv1.ConditionSeverityInfo, bootstrapv1.WaitingForClusterInfrastructureReason)
}
Expand Down Expand Up @@ -1566,7 +1566,7 @@ func TestKubeadmConfigReconciler_Reconcile_DiscoveryReconcileFailureBehaviors(t
g := NewWithT(t)

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

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

users, err := k.resolveUsers(ctx, tc.cfg)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(users).To(Equal(tc.expect))
g.Expect(users).To(BeComparableTo(tc.expect))
for _, user := range tc.cfg.Spec.Users {
if passwdFrom[user.Name] {
g.Expect(user.PasswdFrom).NotTo(BeNil())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestUnmarshalJSON(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(newbts).To(Equal(rt.bts))
g.Expect(newbts).To(BeComparableTo(rt.bts))
})
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestNewBootstrapTokenString(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(actual).To(Equal(rt.bts))
g.Expect(actual).To(BeComparableTo(rt.bts))
})
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestNewBootstrapTokenStringFromIDAndSecret(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(actual).To(Equal(rt.bts))
g.Expect(actual).To(BeComparableTo(rt.bts))
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestUnmarshalJSON(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(newbts).To(Equal(rt.bts))
g.Expect(newbts).To(BeComparableTo(rt.bts))
})
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestNewBootstrapTokenString(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(actual).To(Equal(rt.bts))
g.Expect(actual).To(BeComparableTo(rt.bts))
})
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestNewBootstrapTokenStringFromIDAndSecret(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(actual).To(Equal(rt.bts))
g.Expect(actual).To(BeComparableTo(rt.bts))
})
}
}
10 changes: 5 additions & 5 deletions bootstrap/kubeadm/types/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestKubeVersionToKubeadmAPIGroupVersion(t *testing.T) {
return
}
g.Expect(err).ToNot(HaveOccurred())
g.Expect(got).To(Equal(tt.want))
g.Expect(got).To(BeComparableTo(tt.want))
})
}
}
Expand Down Expand Up @@ -496,7 +496,7 @@ func TestUnmarshalClusterConfiguration(t *testing.T) {
return
}
g.Expect(err).ToNot(HaveOccurred())
g.Expect(got).To(Equal(tt.want), cmp.Diff(tt.want, got))
g.Expect(got).To(BeComparableTo(tt.want), cmp.Diff(tt.want, got))
})
}
}
Expand Down Expand Up @@ -551,7 +551,7 @@ func TestUnmarshalClusterStatus(t *testing.T) {
return
}
g.Expect(err).ToNot(HaveOccurred())
g.Expect(got).To(Equal(tt.want), cmp.Diff(tt.want, got))
g.Expect(got).To(BeComparableTo(tt.want), cmp.Diff(tt.want, got))
})
}
}
Expand Down Expand Up @@ -610,7 +610,7 @@ func TestUnmarshalInitConfiguration(t *testing.T) {
return
}
g.Expect(err).ToNot(HaveOccurred())
g.Expect(got).To(Equal(tt.want), cmp.Diff(tt.want, got))
g.Expect(got).To(BeComparableTo(tt.want), cmp.Diff(tt.want, got))
})
}
}
Expand Down Expand Up @@ -669,7 +669,7 @@ func TestUnmarshalJoinConfiguration(t *testing.T) {
return
}
g.Expect(err).ToNot(HaveOccurred())
g.Expect(got).To(Equal(tt.want), cmp.Diff(tt.want, got))
g.Expect(got).To(BeComparableTo(tt.want), cmp.Diff(tt.want, got))
})
}
}
2 changes: 1 addition & 1 deletion cmd/clusterctl/api/v1alpha3/metadata_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestGetReleaseSeriesForContract(t *testing.T) {
g := NewWithT(t)

m := &Metadata{ReleaseSeries: test.releaseSeries}
g.Expect(m.GetReleaseSeriesForContract(test.contract)).To(Equal(test.expectedReleaseSeries))
g.Expect(m.GetReleaseSeriesForContract(test.contract)).To(BeComparableTo(test.expectedReleaseSeries))
})
}
}
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/cert_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ func Test_certManagerClient_PlanUpgrade(t *testing.T) {
actualPlan, err := cm.PlanUpgrade()
if tt.expectErr {
g.Expect(err).To(HaveOccurred())
g.Expect(actualPlan).To(Equal(CertManagerUpgradePlan{}))
g.Expect(actualPlan).To(BeComparableTo(CertManagerUpgradePlan{}))
return
}
g.Expect(err).ToNot(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/mover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ func Test_objectMover_restoreTargetObject(t *testing.T) {
g.Expect(oAfter.GetName()).Should(Equal(oTo.GetName()))
g.Expect(oAfter.GetCreationTimestamp()).Should(Equal(oTo.GetCreationTimestamp()))
g.Expect(oAfter.GetUID()).Should(Equal(oTo.GetUID()))
g.Expect(oAfter.GetOwnerReferences()).Should(Equal(oTo.GetOwnerReferences()))
g.Expect(oAfter.GetOwnerReferences()).Should(BeComparableTo(oTo.GetOwnerReferences()))
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func Test_topologyClient_Plan(t *testing.T) {
g.Expect(res.ReconciledCluster).To(BeNil())
} else {
g.Expect(res.ReconciledCluster).NotTo(BeNil())
g.Expect(*res.ReconciledCluster).To(Equal(*tt.want.reconciledCluster))
g.Expect(*res.ReconciledCluster).To(BeComparableTo(*tt.want.reconciledCluster))
}

// Check the created objects.
Expand Down
4 changes: 2 additions & 2 deletions cmd/clusterctl/client/cluster/upgrader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func Test_providerUpgrader_Plan(t *testing.T) {
}

g.Expect(err).ToNot(HaveOccurred())
g.Expect(got).To(Equal(tt.want), cmp.Diff(got, tt.want))
g.Expect(got).To(BeComparableTo(tt.want), cmp.Diff(got, tt.want))
})
}
}
Expand Down Expand Up @@ -869,7 +869,7 @@ func Test_providerUpgrader_createCustomPlan(t *testing.T) {
}

g.Expect(err).ToNot(HaveOccurred())
g.Expect(got).To(Equal(tt.want))
g.Expect(got).To(BeComparableTo(tt.want))
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/clusterctl/client/config/reader_memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ func TestMemoryReader(t *testing.T) {

providersOut := []configProvider{}
g.Expect(f.UnmarshalKey("providers", &providersOut)).To(Succeed())
g.Expect(providersOut).To(Equal(tt.providers))
g.Expect(providersOut).To(BeComparableTo(tt.providers))

imagesOut := map[string]imageMeta{}
g.Expect(f.UnmarshalKey("images", &imagesOut)).To(Succeed())
g.Expect(imagesOut).To(Equal(tt.imageMetas))
g.Expect(imagesOut).To(BeComparableTo(tt.imageMetas))

for n, v := range tt.variables {
outV, err := f.Get(n)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func Test_clusterctlClient_Delete(t *testing.T) {
gotProvidersSet.Insert(gotProvider.Name)
}

g.Expect(gotProvidersSet).To(Equal(tt.wantProviders))
g.Expect(gotProvidersSet).To(BeComparableTo(tt.wantProviders))
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/clusterctl/client/repository/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ func Test_addCommonLabels(t *testing.T) {
g := NewWithT(t)

got := addCommonLabels(tt.args.objs, config.NewProvider(tt.args.name, "", tt.args.providerType))
g.Expect(got).To(Equal(tt.want))
g.Expect(got).To(BeComparableTo(tt.want))
})
}
}
Expand Down Expand Up @@ -721,5 +721,5 @@ func TestAlterComponents(t *testing.T) {
if err := AlterComponents(c, alterFn); err != nil {
t.Errorf("AlterComponents() error = %v", err)
}
g.Expect(c.objs).To(Equal(want))
g.Expect(c.objs).To(BeComparableTo(want))
}
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/repository/metadata_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func Test_metadataClient_Get(t *testing.T) {
}
g.Expect(err).ToNot(HaveOccurred())

g.Expect(got).To(Equal(tt.want))
g.Expect(got).To(BeComparableTo(tt.want))
})
}
}
4 changes: 2 additions & 2 deletions cmd/clusterctl/client/tree/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func Test_createGroupNode(t *testing.T) {
want.SetName(got.GetName())
want.SetUID(got.GetUID())

g.Expect(got).To(Equal(want))
g.Expect(got).To(BeComparableTo(want))
}

func Test_updateGroupNode(t *testing.T) {
Expand Down Expand Up @@ -367,7 +367,7 @@ func Test_updateGroupNode(t *testing.T) {
g := NewWithT(t)
updateGroupNode(group, GetReadyCondition(group), obj, GetReadyCondition(obj))

g.Expect(group).To(Equal(want))
g.Expect(group).To(BeComparableTo(want))
}

func Test_Add_setsShowObjectConditionsAnnotation(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions cmd/clusterctl/client/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ func Test_clusterctlClient_PlanCertUpgrade(t *testing.T) {
actualPlan, err := tt.client.PlanCertManagerUpgrade(options)
if tt.expectErr {
g.Expect(err).To(HaveOccurred())
g.Expect(actualPlan).To(Equal(CertManagerUpgradePlan{}))
g.Expect(actualPlan).To(BeComparableTo(CertManagerUpgradePlan{}))
return
}
g.Expect(err).ToNot(HaveOccurred())
g.Expect(actualPlan).To(Equal(certManagerPlan))
g.Expect(actualPlan).To(BeComparableTo(certManagerPlan))
})
}
}
Expand Down Expand Up @@ -300,7 +300,7 @@ func Test_clusterctlClient_ApplyUpgrade(t *testing.T) {
for i := range gotProviders.Items {
tt.wantProviders.Items[i].ResourceVersion = gotProviders.Items[i].ResourceVersion
}
g.Expect(gotProviders).To(Equal(tt.wantProviders), cmp.Diff(gotProviders, tt.wantProviders))
g.Expect(gotProviders).To(BeComparableTo(tt.wantProviders), cmp.Diff(gotProviders, tt.wantProviders))
})
}
}
Expand Down Expand Up @@ -476,7 +476,7 @@ func Test_parseUpgradeItem(t *testing.T) {
}
g.Expect(err).ToNot(HaveOccurred())

g.Expect(got).To(Equal(tt.want))
g.Expect(got).To(BeComparableTo(tt.want))
})
}
}
2 changes: 1 addition & 1 deletion cmd/clusterctl/cmd/version_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func TestVersionChecker_WriteStateFile(t *testing.T) {
g.Expect(err).ToNot(HaveOccurred())
var actualVersionState VersionState
g.Expect(yaml.Unmarshal(fb, &actualVersionState)).To(Succeed())
g.Expect(actualVersionState.LatestRelease).To(Equal(*release))
g.Expect(actualVersionState.LatestRelease).To(BeComparableTo(*release))
}

func TestVersionChecker_ReadFromStateFile(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions controllers/external/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestGetResourceFound(t *testing.T) {
fakeClient := fake.NewClientBuilder().WithObjects(testResource.DeepCopy()).Build()
got, err := Get(ctx, fakeClient, testResourceReference, metav1.NamespaceDefault)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(got).To(Equal(testResource))
g.Expect(got).To(BeComparableTo(testResource))
}

func TestGetResourceNotFound(t *testing.T) {
Expand Down Expand Up @@ -203,7 +203,7 @@ func TestCloneTemplateResourceFound(t *testing.T) {
cloneSpec, ok, err := unstructured.NestedMap(clone.UnstructuredContent(), "spec")
g.Expect(err).ToNot(HaveOccurred())
g.Expect(ok).To(BeTrue())
g.Expect(cloneSpec).To(Equal(expectedSpec))
g.Expect(cloneSpec).To(BeComparableTo(expectedSpec))

cloneLabels := clone.GetLabels()
g.Expect(cloneLabels).To(HaveKeyWithValue(clusterv1.ClusterNameLabel, testClusterName))
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestCloneTemplateResourceFoundNoOwner(t *testing.T) {
cloneSpec, ok, err := unstructured.NestedMap(clone.UnstructuredContent(), "spec")
g.Expect(err).ToNot(HaveOccurred())
g.Expect(ok).To(BeTrue())
g.Expect(cloneSpec).To(Equal(expectedSpec))
g.Expect(cloneSpec).To(BeComparableTo(expectedSpec))
}

func TestCloneTemplateMissingSpecTemplate(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion controllers/noderefutil/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func TestGetReadyCondition(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
g := NewWithT(t)

g.Expect(GetReadyCondition(test.nodeStatus)).To(Equal(test.expectedCondition))
g.Expect(GetReadyCondition(test.nodeStatus)).To(BeComparableTo(test.expectedCondition))
})
}
}
Expand Down
Loading

0 comments on commit c79c7d3

Please sign in to comment.