Skip to content

Commit

Permalink
Add test to validate status is set correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
lmm committed Jun 30, 2020
1 parent 76757c0 commit 32c8450
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/mainline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package test
import (
"context"
"fmt"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -125,6 +126,38 @@ var _ = Describe("Mainline component function tests", func() {

It("Should install resources for a CRD", func() {
stopChan := installResourceCRD(c, mgr)

instance := &operator.Installation{
TypeMeta: metav1.TypeMeta{Kind: "Installation", APIVersion: "operator.tigera.io/v1"},
ObjectMeta: metav1.ObjectMeta{Name: "default"},
}
By("Checking that the installation status is set correctly")
Eventually(func() error {
err := GetResource(c, instance)
if err != nil {
return err
}
if instance.Status.Variant != operator.Calico {
return fmt.Errorf("installation status not Calico yet")
}
return nil
}, 60*time.Second).Should(BeNil())

By("Checking that the installation status does not change")
Consistently(func() error {
err := GetResource(c, instance)
if err != nil {
return err
}
if reflect.DeepEqual(instance.Status, operator.InstallationStatus{}) {
return fmt.Errorf("installation status is empty")
}
if instance.Status.Variant != operator.Calico {
return fmt.Errorf("installation status was %v, expected: %v", instance.Status, operator.Calico)
}
return nil
}, 30*time.Second, 50*time.Millisecond).Should(BeNil())

defer close(stopChan)
})
})
Expand Down

0 comments on commit 32c8450

Please sign in to comment.