Skip to content

Commit

Permalink
Add integration tests to check resource keys in bundle status
Browse files Browse the repository at this point in the history
  • Loading branch information
rubhanazeem committed Jun 19, 2024
1 parent 482b67d commit 299e442
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions integrationtests/controller/bundle/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var _ = Describe("Bundle Status Fields", func() {
ClusterName: "cluster",
},
}

bundle, err := utils.CreateBundle(ctx, k8sClient, "name", namespace, targets, targets)
Expect(err).NotTo(HaveOccurred())
Expect(bundle).To(Not(BeNil()))
Expand Down Expand Up @@ -70,25 +71,42 @@ var _ = Describe("Bundle Status Fields", func() {
if err != nil {
return err
}
resources := []v1alpha1.BundleDeploymentResource{}
resource := v1alpha1.BundleDeploymentResource{
Kind: "ConfigMap",
APIVersion: "v1",
Namespace: namespace,
Name: "app-config",
}
resources = append(resources, resource)
bd.Status.Display.State = "Ready"
bd.Status.AppliedDeploymentID = bd.Spec.DeploymentID
bd.Status.Ready = true
bd.Status.NonModified = true
bd.Status.Resources = resources
return k8sClient.Status().Update(ctx, bd)
}).ShouldNot(HaveOccurred())

err = k8sClient.Get(ctx, types.NamespacedName{Namespace: namespace, Name: "name"}, bd)
Expect(err).NotTo(HaveOccurred())
Expect(bd.Status.Display.State).To(Equal("Ready"))
Expect(bd.Status.AppliedDeploymentID).To(Equal(bd.Spec.DeploymentID))
Expect(bd.Status.Resources).ToNot(BeNil())

bdResource := bd.Status.Resources[0]
Eventually(func() bool {
err = k8sClient.Get(ctx, types.NamespacedName{Namespace: namespace, Name: "name"}, bundle)
Expect(err).NotTo(HaveOccurred())
return bundle.Status.Summary.Ready == 1
}).Should(BeTrue())
bundleResourceKey := bundle.Status.ResourceKey[0]
Expect(bundle.Status.Summary.DesiredReady).To(Equal(1))
Expect(bundle.Status.Display.ReadyClusters).To(Equal("1/1"))
Expect(bundle.Status.ResourceKey).ToNot(BeNil())
Expect(bundleResourceKey.APIVersion).To(Equal(bdResource.APIVersion))
Expect(bundleResourceKey.Name).To(Equal(bdResource.Name))
Expect(bundleResourceKey.Namespace).To(Equal(bdResource.Namespace))
Expect(bundleResourceKey.Kind).To(Equal(bdResource.Kind))
})
})

Expand Down

0 comments on commit 299e442

Please sign in to comment.