|
| 1 | +package defaults |
| 2 | + |
| 3 | +import ( |
| 4 | + "reflect" |
| 5 | + |
| 6 | + . "github.com/onsi/ginkgo/v2" |
| 7 | + . "github.com/onsi/gomega" |
| 8 | +) |
| 9 | + |
| 10 | +var _ = Describe("instance test", func() { |
| 11 | + var ( |
| 12 | + instanceID string |
| 13 | + instance *HelmAppInstance |
| 14 | + ) |
| 15 | + |
| 16 | + // main logic to get the default instance |
| 17 | + JustBeforeEach(func() { |
| 18 | + instance = GetDefaultHelmAppInstanceByInstanceID(instanceID) |
| 19 | + }) |
| 20 | + |
| 21 | + Context("GetDefaultHelmAppInstanceByInstanceID", func() { |
| 22 | + When("instanceID is not exists", func() { |
| 23 | + BeforeEach(func() { |
| 24 | + instanceID = "not-exists" |
| 25 | + }) |
| 26 | + It("should return nil", func() { |
| 27 | + // main logic is in JustBeforeEach |
| 28 | + Expect(instance).To(BeNil()) |
| 29 | + }) |
| 30 | + }) |
| 31 | + |
| 32 | + When("instanceID is exists(argocd)", func() { |
| 33 | + JustAfterEach(func() { |
| 34 | + Expect(instance).NotTo(BeNil()) |
| 35 | + Expect(instance.Name).To(Equal("argocd")) |
| 36 | + Expect(*instance.HelmOptions).To(Equal(DefaultConfigWithArgoCD)) |
| 37 | + pointer1 := reflect.ValueOf(instance.StatusGetter).Pointer() |
| 38 | + pointer2 := reflect.ValueOf(GetArgoCDStatus).Pointer() |
| 39 | + Expect(pointer1).To(Equal(pointer2)) |
| 40 | + }) |
| 41 | + When(`instanceID is the same as "argocd"`, func() { |
| 42 | + BeforeEach(func() { |
| 43 | + instanceID = "argocd" |
| 44 | + }) |
| 45 | + It("should return instance", func() { |
| 46 | + // main logic is in JustAfterEach |
| 47 | + }) |
| 48 | + }) |
| 49 | + |
| 50 | + When(`instanceID has prefix "argocd"`, func() { |
| 51 | + BeforeEach(func() { |
| 52 | + instanceID = "argocd-001" |
| 53 | + }) |
| 54 | + It("should return instance", func() { |
| 55 | + // main logic is in JustAfterEach |
| 56 | + }) |
| 57 | + }) |
| 58 | + }) |
| 59 | + }) |
| 60 | +}) |
0 commit comments