Skip to content

Commit f33ed23

Browse files
Microzuul CIGerrit Code Review
authored andcommitted
Merge "Add Dump Config INI test"
2 parents 52b4aa8 + 0a07afd commit f33ed23

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

controllers/zuul_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
. "github.com/onsi/ginkgo/v2"
1414
. "github.com/onsi/gomega"
1515
sfv1 "github.com/softwarefactory-project/sf-operator/api/v1"
16+
17+
"gopkg.in/ini.v1"
1618
corev1 "k8s.io/api/core/v1"
1719
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1820
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -86,4 +88,35 @@ var _ = Describe("Zuul controller", func() {
8688
}, 10*time.Second, time.Second).Should(Succeed())
8789
})
8890
})
91+
Context("DumpConfigINI test", func() {
92+
It("should sort keys alphabetically within each section", func() {
93+
94+
cfg := ini.Empty()
95+
sec, err := cfg.NewSection("zookeeper")
96+
Expect(err).ToNot(HaveOccurred())
97+
_, err = sec.NewKey("hosts", "zookeeper.sfoperator.svc:2281")
98+
Expect(err).ToNot(HaveOccurred())
99+
_, err = sec.NewKey("ca", "/tls/client/ca.crt")
100+
Expect(err).ToNot(HaveOccurred())
101+
102+
sec2, err := cfg.NewSection("scheduler")
103+
Expect(err).ToNot(HaveOccurred())
104+
_, err = sec2.NewKey("max_hold_expiration", "86400")
105+
Expect(err).ToNot(HaveOccurred())
106+
_, err = sec2.NewKey("default_hold_expiration", "3600")
107+
Expect(err).ToNot(HaveOccurred())
108+
109+
actual := DumpConfigINI(cfg)
110+
111+
expected := `[zookeeper]
112+
ca = /tls/client/ca.crt
113+
hosts = zookeeper.sfoperator.svc:2281
114+
115+
[scheduler]
116+
default_hold_expiration = 3600
117+
max_hold_expiration = 86400
118+
`
119+
Expect(actual).To(Equal(expected))
120+
})
121+
})
89122
})

0 commit comments

Comments
 (0)