Skip to content

Commit

Permalink
cleaned up test formatting
Browse files Browse the repository at this point in the history
Signed-off-by: dtfranz <dfranz@redhat.com>
  • Loading branch information
dtfranz committed Jan 26, 2023
1 parent 372f8ad commit a06520c
Showing 1 changed file with 25 additions and 30 deletions.
55 changes: 25 additions & 30 deletions test/e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,37 @@ const (
)

var _ = Describe("Operator Install", func() {
When("a valid Operator CR specifying a package", func() {
It("resolves the specified package with correct bundle path", func() {
var (
operator *operatorv1alpha1.Operator
ctx context.Context
err error
)
BeforeEach(func() {
ctx = context.Background()
operator = &operatorv1alpha1.Operator{
ctx context.Context = context.Background()
pkgName string = "prometheus"
operator *operatorv1alpha1.Operator = &operatorv1alpha1.Operator{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("operator-%s", rand.String(8)),
},
Spec: operatorv1alpha1.OperatorSpec{
PackageName: "prometheus",
PackageName: pkgName,
},
}
})
AfterEach(func() {
By("deleting the testing Operator resource")
err = c.Delete(ctx, operator)
Expect(err).ToNot(HaveOccurred())
})
It("resolves the specified package with correct bundle path", func() {
By("creating an operator CR")
err = c.Create(ctx, operator)
Expect(err).ToNot(HaveOccurred())
// TODO dfranz: This test currently relies on the hard-coded CatalogSources found in bundle_cache.go
// and should be re-worked to use a real or test catalog source when the hard-coded stuff is removed
By("operator CR status is updated with correct bundle path")
Eventually(func(g Gomega) {
err = c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(operator.Status.BundlePath).To(Equal("operatorhub/prometheus/0.47.0"))
g.Expect(len(operator.Status.Conditions)).To(Equal(1))
g.Expect(operator.Status.Conditions[0].Message).To(Equal("resolution was successful"))
}).WithTimeout(defaultTimeout).WithPolling(defaultPoll).Should(Succeed())
})
)
ctx = context.Background()
By("creating the Operator resource")
err := c.Create(ctx, operator)
Expect(err).ToNot(HaveOccurred())

// TODO dfranz: This test currently relies on the hard-coded CatalogSources found in bundle_cache.go
// and should be re-worked to use a real or test catalog source when the hard-coded stuff is removed
By("eventually reporting a successful resolution and bundle path")
Eventually(func(g Gomega) {
err = c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(operator.Status.BundlePath).To(Equal("operatorhub/prometheus/0.47.0"))
g.Expect(len(operator.Status.Conditions)).To(Equal(1))
g.Expect(operator.Status.Conditions[0].Message).To(Equal("resolution was successful"))
}).WithTimeout(defaultTimeout).WithPolling(defaultPoll).Should(Succeed())

By("deleting the Operator resource")
err = c.Delete(ctx, operator)
Expect(err).ToNot(HaveOccurred())
})
})

0 comments on commit a06520c

Please sign in to comment.