This repository has been archived by the owner on Feb 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig_test.go
61 lines (52 loc) · 1.82 KB
/
config_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package config
import (
"os"
"runtime"
"testing"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestChoria(t *testing.T) {
os.Setenv("MCOLLECTIVE_CERTNAME", "rip.mcollective")
RegisterFailHandler(Fail)
RunSpecs(t, "Config")
}
var _ = Describe("Choria/Config", func() {
var _ = Describe("NewConfig", func() {
It("Should correctly parse config files", func() {
var c *Config
var err error
if runtime.GOOS == "windows" {
c, err = NewConfig("testdata/choria_windows.cfg")
} else {
c, err = NewConfig("testdata/choria.cfg")
}
Expect(err).ToNot(HaveOccurred())
Expect(c.Choria.NetworkWriteDeadline).To(Equal(10 * time.Second))
Expect(c.Choria.DiscoveryHost).To(Equal("pdb.example.com"))
Expect(c.Registration).To(Equal([]string{"foo"}))
Expect(c.RegisterInterval).To(Equal(10))
Expect(c.RegistrationSplay).To(BeTrue())
Expect(c.Collectives).To(Equal([]string{"c_1", "c_2", "c_3"}))
Expect(c.MainCollective).To(Equal("c_1"))
Expect(c.KeepLogs).To(Equal(5))
Expect(c.LibDir).To(Equal([]string{"/dir1", "/dir2", "/dir3", "/dir4"}))
Expect(c.DefaultDiscoveryOptions).To(Equal([]string{"one", "two"}))
Expect(c.Choria.RandomizeMiddlewareHosts).To(BeTrue())
Expect(c.Choria.PrivilegedUsers).To(Equal([]string{
"\\.privileged.mcollective$",
"\\.privileged.choria$",
}))
Expect(c.Choria.CertnameWhitelist).To(Equal([]string{
"\\.mcollective$",
"\\.choria$",
}))
Expect(c.Option("plugin.package.setting", "default")).To(Equal("1"))
Expect(c.Option("plugin.package.other_setting", "default")).To(Equal("default"))
c.SetOption("plugin.package.other_setting", "override")
Expect(c.Option("plugin.package.setting", "default")).To(Equal("1"))
Expect(c.Option("plugin.package.other_setting", "default")).To(Equal("override"))
})
})
})