Skip to content

Commit

Permalink
Initially done
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhairya-Arora01 committed Jul 20, 2023
1 parent fdf395e commit 5238074
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func Test_dropDiffForNotAllowedPaths(t *testing.T) {

dropDiff(tt.ctx)

g.Expect(tt.ctx.modified).To(Equal(tt.wantModified))
g.Expect(tt.ctx.modified).To(BeComparableTo(tt.wantModified))
})
}
}
Expand Down Expand Up @@ -268,7 +268,7 @@ func Test_dropDiffForIgnoredPaths(t *testing.T) {

dropDiff(tt.ctx)

g.Expect(tt.ctx.modified).To(Equal(tt.wantModified))
g.Expect(tt.ctx.modified).To(BeComparableTo(tt.wantModified))
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ func TestServerSideApplyWithDefaulting(t *testing.T) {

// Ensure patchKCT was defaulted.
g.Expect(env.Get(ctx, client.ObjectKeyFromObject(kct), patchKCT)).To(Succeed())
g.Expect(patchKCT.Spec.Template.Spec.Users).To(Equal([]bootstrapv1.User{{Name: "default-user"}}))
g.Expect(patchKCT.Spec.Template.Spec.Users).To(BeComparableTo([]bootstrapv1.User{{Name: "default-user"}}))
}, 5*time.Second).Should(Succeed())
}
// Get original for the update.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ func Test_DefaultClusterVariables(t *testing.T) {
return
}
g.Expect(errList).To(BeEmpty())
g.Expect(vars).To(Equal(tt.want))
g.Expect(vars).To(BeComparableTo(tt.want))
})
}
}
Expand Down Expand Up @@ -1195,7 +1195,7 @@ func Test_DefaultClusterVariable(t *testing.T) {
}
g.Expect(errList).To(BeEmpty())

g.Expect(defaultedVariable).To(Equal(tt.want))
g.Expect(defaultedVariable).To(BeComparableTo(tt.want))
})
}
}
Expand Down Expand Up @@ -1337,6 +1337,6 @@ func Test_getAllVariables(t *testing.T) {
valuesIndex, err := newValuesIndex(values)
g.Expect(err).ToNot(HaveOccurred())
got := getAllVariables(values, valuesIndex, definitions)
g.Expect(got).To(Equal(expectedValues))
g.Expect(got).To(BeComparableTo(expectedValues))
})
}
4 changes: 2 additions & 2 deletions internal/util/ssa/filterintent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func Test_filterNotAllowedPaths(t *testing.T) {

FilterIntent(tt.ctx)

g.Expect(tt.ctx.Value).To(Equal(tt.wantValue))
g.Expect(tt.ctx.Value).To(BeComparableTo(tt.wantValue))
})
}
}
Expand Down Expand Up @@ -195,7 +195,7 @@ func Test_filterIgnoredPaths(t *testing.T) {

FilterIntent(tt.ctx)

g.Expect(tt.ctx.Value).To(Equal(tt.wantValue))
g.Expect(tt.ctx.Value).To(BeComparableTo(tt.wantValue))
})
}
}
2 changes: 1 addition & 1 deletion internal/util/taints/taints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestRemoveNodeTaint(t *testing.T) {
g := NewWithT(t)
got := RemoveNodeTaint(tt.node, tt.dropTaint)
g.Expect(got).To(Equal(tt.wantModified))
g.Expect(tt.node.Spec.Taints).To(Equal(tt.wantTaints))
g.Expect(tt.node.Spec.Taints).To(BeComparableTo(tt.wantTaints))
})
}
}
4 changes: 2 additions & 2 deletions internal/webhooks/runtime/extensionconfig_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ func TestExtensionConfigDefault(t *testing.T) {
t.Run("for Extension", util.CustomDefaultValidateTest(ctx, extensionConfig, extensionConfigWebhook))

g.Expect(extensionConfigWebhook.Default(ctx, extensionConfig)).To(Succeed())
g.Expect(extensionConfig.Spec.NamespaceSelector).To(Equal(&metav1.LabelSelector{}))
g.Expect(extensionConfig.Spec.ClientConfig.Service.Port).To(Equal(pointer.Int32(443)))
g.Expect(extensionConfig.Spec.NamespaceSelector).To(BeComparableTo(&metav1.LabelSelector{}))
g.Expect(extensionConfig.Spec.ClientConfig.Service.Port).To(BeComparableTo(pointer.Int32(443)))
}

func TestExtensionConfigValidate(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/clusterclass_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func assertMachineDeploymentTopologyFields(g Gomega, md clusterv1.MachineDeploym
}

if mdTopology.Strategy != nil {
g.Expect(md.Spec.Strategy).To(Equal(mdTopology.Strategy))
g.Expect(md.Spec.Strategy).To(BeComparableTo(mdTopology.Strategy))
}

if mdTopology.FailureDomain != nil {
Expand Down
8 changes: 4 additions & 4 deletions test/extension/handlers/topologymutation/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func Test_patchDockerClusterTemplate(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(tt.template).To(Equal(tt.expectedTemplate))
g.Expect(tt.template).To(BeComparableTo(tt.expectedTemplate))
})
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ func Test_patchKubeadmControlPlaneTemplate(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(tt.template).To(Equal(tt.expectedTemplate))
g.Expect(tt.template).To(BeComparableTo(tt.expectedTemplate))
})
}
}
Expand Down Expand Up @@ -283,7 +283,7 @@ func Test_patchKubeadmConfigTemplate(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(tt.template).To(Equal(tt.expectedTemplate))
g.Expect(tt.template).To(BeComparableTo(tt.expectedTemplate))
})
}
}
Expand Down Expand Up @@ -334,7 +334,7 @@ func Test_patchDockerMachineTemplate(t *testing.T) {
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(tt.template).To(Equal(tt.expectedTemplate))
g.Expect(tt.template).To(BeComparableTo(tt.expectedTemplate))
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/framework/machinedeployment_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func UpgradeMachineDeploymentInfrastructureRefAndWait(ctx context.Context, input
g.Expect(*newMachineSet.Spec.Replicas).To(Equal(newMachineSet.Status.AvailableReplicas))

// MachineSet should have the same infrastructureRef as the MachineDeployment.
g.Expect(newMachineSet.Spec.Template.Spec.InfrastructureRef).To(Equal(deployment.Spec.Template.Spec.InfrastructureRef))
g.Expect(newMachineSet.Spec.Template.Spec.InfrastructureRef).To(BeComparableTo(deployment.Spec.Template.Spec.InfrastructureRef))
}, input.WaitForMachinesToBeUpgraded...).Should(Succeed())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ runcmd:
g.Expect(r.Cmds).To(HaveLen(2))

expected0 := provisioning.Cmd{Cmd: "ls", Args: []string{"-l", "/"}}
g.Expect(r.Cmds[0]).To(Equal(expected0))
g.Expect(r.Cmds[0]).To(BeComparableTo(expected0))

expected1 := provisioning.Cmd{Cmd: "/bin/sh", Args: []string{"-c", "ls -l /"}}
g.Expect(r.Cmds[1]).To(Equal(expected1))
g.Expect(r.Cmds[1]).To(BeComparableTo(expected1))
}

func TestRunCmdRun(t *testing.T) {
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestRunCmdRun(t *testing.T) {

commands, err := rt.r.Commands()
g.Expect(err).ToNot(HaveOccurred())
g.Expect(rt.expectedCmds).To(Equal(commands))
g.Expect(rt.expectedCmds).To(BeComparableTo(commands))
})
}
}
Expand All @@ -102,10 +102,10 @@ runcmd:
r.Cmds[0] = hackKubeadmIgnoreErrors(r.Cmds[0])

expected0 := provisioning.Cmd{Cmd: "/bin/sh", Args: []string{"-c", "kubeadm init --ignore-preflight-errors=SystemVerification,Swap,FileContent--proc-sys-net-bridge-bridge-nf-call-iptables --config=/run/kubeadm/kubeadm.yaml"}}
g.Expect(r.Cmds[0]).To(Equal(expected0))
g.Expect(r.Cmds[0]).To(BeComparableTo(expected0))

r.Cmds[1] = hackKubeadmIgnoreErrors(r.Cmds[1])

expected1 := provisioning.Cmd{Cmd: "kubeadm", Args: []string{"join", "--ignore-preflight-errors=SystemVerification,Swap,FileContent--proc-sys-net-bridge-bridge-nf-call-iptables", "--config=/run/kubeadm/kubeadm-controlplane-join-config.yaml"}}
g.Expect(r.Cmds[1]).To(Equal(expected1))
g.Expect(r.Cmds[1]).To(BeComparableTo(expected1))
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestWriteFiles(t *testing.T) {

cmds, err := rt.w.Commands()
g.Expect(err).ToNot(HaveOccurred())
g.Expect(rt.expectedCmds).To(Equal(cmds))
g.Expect(rt.expectedCmds).To(BeComparableTo(cmds))
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func Test_cache_client(t *testing.T) {
g.Expect(c.resourceGroups["foo"].objects[cloudv1.GroupVersion.WithKind(cloudv1.CloudMachineKind)]).To(HaveKey(key), "Object bar must exists in object tracker for foo")

r := c.resourceGroups["foo"].objects[cloudv1.GroupVersion.WithKind(cloudv1.CloudMachineKind)][key]
g.Expect(r.GetObjectKind().GroupVersionKind()).To(Equal(cloudv1.GroupVersion.WithKind(cloudv1.CloudMachineKind)), "gvk must be set")
g.Expect(r.GetObjectKind().GroupVersionKind()).To(BeComparableTo(cloudv1.GroupVersion.WithKind(cloudv1.CloudMachineKind)), "gvk must be set")
g.Expect(r.GetName()).To(Equal("bar"), "name must be equal to object tracker key")
g.Expect(r.GetResourceVersion()).To(Equal("v1"), "resourceVersion must be set")
g.Expect(r.GetCreationTimestamp()).ToNot(BeZero(), "creation timestamp must be set")
Expand Down Expand Up @@ -269,7 +269,7 @@ func Test_cache_client(t *testing.T) {
g.Expect(err).ToNot(HaveOccurred())

// Check all the computed fields are as expected.
g.Expect(obj.GetObjectKind().GroupVersionKind()).To(Equal(cloudv1.GroupVersion.WithKind(cloudv1.CloudMachineKind)), "gvk must be set")
g.Expect(obj.GetObjectKind().GroupVersionKind()).To(BeComparableTo(cloudv1.GroupVersion.WithKind(cloudv1.CloudMachineKind)), "gvk must be set")
g.Expect(obj.GetName()).To(Equal("bar"), "name must be equal to object tracker key")
g.Expect(obj.GetResourceVersion()).To(Equal("v1"), "resourceVersion must be set")
g.Expect(obj.GetCreationTimestamp()).ToNot(BeZero(), "creation timestamp must be set")
Expand Down Expand Up @@ -412,7 +412,7 @@ func Test_cache_client(t *testing.T) {
err = c.Update("foo", objUpdate)
g.Expect(err).ToNot(HaveOccurred())

g.Expect(objBefore).To(Equal(objUpdate), "obj before and after must be the same")
g.Expect(objBefore).To(BeComparableTo(objUpdate), "obj before and after must be the same")

g.Expect(h.Events()).ToNot(ContainElement("foo, CloudMachine=bar, Updated"))
})
Expand All @@ -435,7 +435,7 @@ func Test_cache_client(t *testing.T) {
g.Expect(objBefore.GetResourceVersion()).ToNot(Equal(objUpdate.GetResourceVersion()), "Object version must be changed")
objBefore.SetResourceVersion(objUpdate.GetResourceVersion())
objBefore.Labels = objUpdate.Labels
g.Expect(objBefore).To(Equal(objUpdate), "everything else must be the same")
g.Expect(objBefore).To(BeComparableTo(objUpdate), "everything else must be the same")

g.Expect(h.Events()).To(ContainElement("foo, CloudMachine=baz, Updated"))
})
Expand Down Expand Up @@ -670,7 +670,7 @@ func Test_cache_client(t *testing.T) {
g.Expect(objBefore.GetResourceVersion()).ToNot(Equal(objAfterUpdate.GetResourceVersion()), "Object version must be changed")
objBefore.SetResourceVersion(objAfterUpdate.GetResourceVersion())
objBefore.Labels = objAfterUpdate.Labels
g.Expect(objBefore).To(Equal(objAfterUpdate), "everything else must be the same")
g.Expect(objBefore).To(BeComparableTo(objAfterUpdate), "everything else must be the same")

g.Expect(h.Events()).To(ContainElement("foo, CloudMachine=baz, Deleted"))

Expand Down
2 changes: 1 addition & 1 deletion test/infrastructure/inmemory/internal/server/mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func TestAPI_corev1_CRUD(t *testing.T) {

node := &corev1.Node{}
g.Expect(c.Get(ctx, client.ObjectKeyFromObject(n3), node)).To(Succeed())
g.Expect(node.Spec.Taints).To(Equal(taints))
g.Expect(node.Spec.Taints).To(BeComparableTo(taints))

// delete

Expand Down
2 changes: 1 addition & 1 deletion test/infrastructure/kind/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestGetMapping(t *testing.T) {
got := GetMapping(tc.k8sVersion, tc.customImage)

tc.expectedMapping.KubernetesVersion = tc.k8sVersion
g.Expect(got).To(Equal(tc.expectedMapping))
g.Expect(got).To(BeComparableTo(tc.expectedMapping))
})
}
}
4 changes: 2 additions & 2 deletions util/conditions/patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestNewPatch(t *testing.T) {
return
}
g.Expect(err).To(Not(HaveOccurred()))
g.Expect(got).To(Equal(tt.want))
g.Expect(got).To(BeComparableTo(tt.want))
})
}
}
Expand Down Expand Up @@ -337,5 +337,5 @@ func TestApplyDoesNotAlterLastTransitionTime(t *testing.T) {
err = diff.Apply(latest)

g.Expect(err).ToNot(HaveOccurred())
g.Expect(latest.GetConditions()).To(Equal(after.GetConditions()))
g.Expect(latest.GetConditions()).To(BeComparableTo(after.GetConditions()))
}
2 changes: 1 addition & 1 deletion util/conditions/unstructured_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ func TestUnstructuredSetConditions(t *testing.T) {

s := UnstructuredSetter(u)
s.SetConditions(conditions)
g.Expect(s.GetConditions()).To(Equal(conditions))
g.Expect(s.GetConditions()).To(BeComparableTo(conditions))
}
4 changes: 2 additions & 2 deletions util/kubeconfig/kubeconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestNew(t *testing.T) {
g.Expect(actualConfig.Clusters[tc.cluster]).NotTo(BeNil())
g.Expect(actualConfig.Contexts[tc.expectedConfig.CurrentContext]).NotTo(BeNil())
g.Expect(actualConfig.CurrentContext).To(Equal(tc.expectedConfig.CurrentContext))
g.Expect(actualConfig.Contexts).To(Equal(tc.expectedConfig.Contexts))
g.Expect(actualConfig.Contexts).To(BeComparableTo(tc.expectedConfig.Contexts))
}
}

Expand All @@ -199,7 +199,7 @@ func TestGenerateSecretWithOwner(t *testing.T) {
)

g.Expect(kubeconfigSecret).NotTo(BeNil())
g.Expect(kubeconfigSecret).To(Equal(expectedSecret))
g.Expect(kubeconfigSecret).To(BeComparableTo(expectedSecret))
}

func TestGenerateSecret(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestMachineToInfrastructureMapFunc(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
fn := MachineToInfrastructureMapFunc(tc.input)
out := fn(ctx, tc.request)
g.Expect(out).To(Equal(tc.output))
g.Expect(out).To(BeComparableTo(tc.output))
})
}
}
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestClusterToInfrastructureMapFunc(t *testing.T) {

fn := ClusterToInfrastructureMapFunc(context.Background(), tc.input, clientBuilder.Build(), referenceObject)
out := fn(ctx, tc.request)
g.Expect(out).To(Equal(tc.output))
g.Expect(out).To(BeComparableTo(tc.output))
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions util/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestParseMajorMinorPatch(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
out, err := ParseMajorMinorPatch(tc.input)
g.Expect(err != nil).To(Equal(tc.expectError))
g.Expect(out).To(Equal(tc.output))
g.Expect(out).To(BeComparableTo(tc.output))
})
}
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestParseMajorMinorPatchTolerant(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
out, err := ParseMajorMinorPatchTolerant(tc.input)
g.Expect(err != nil).To(Equal(tc.expectError))
g.Expect(out).To(Equal(tc.output))
g.Expect(out).To(BeComparableTo(tc.output))
})
}
}
Expand Down

0 comments on commit 5238074

Please sign in to comment.