-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathconfig_test.go
62 lines (48 loc) · 1.32 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
62
package memfs_test
import (
"io/ioutil"
"path/filepath"
. "github.com/bbengfort/memfs"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func makeTestConfig() *Config {
return &Config{
Name: "testhost",
CacheSize: 4295000000,
Level: "default",
ReadOnly: false,
Replicas: make([]*Replica, 0),
Path: "",
}
}
var _ = Describe("Config", func() {
var err error
var tmpDir string
BeforeEach(func() {
tmpDir, err = ioutil.TempDir("", TempDirPrefix)
Ω(err).ShouldNot(HaveOccurred())
})
It("should create a correct configuration", func() {
config := makeTestConfig()
Ω(config.Name).ShouldNot(BeZero())
Ω(config.CacheSize).ShouldNot(BeZero())
Ω(config.Level).ShouldNot(BeZero())
})
It("should be able to dump and load a config", func() {
alpha := makeTestConfig()
path := filepath.Join(tmpDir, "test-config.json")
err = alpha.Dump(path)
Ω(err).ShouldNot(HaveOccurred())
bravo := new(Config)
err = bravo.Load(path)
Ω(err).ShouldNot(HaveOccurred())
Ω(bravo.Name).Should(Equal(alpha.Name))
Ω(bravo.CacheSize).Should(Equal(alpha.CacheSize))
Ω(bravo.Level).Should(Equal(alpha.Level))
Ω(bravo.ReadOnly).Should(Equal(alpha.ReadOnly))
Ω(bravo.Replicas).Should(Equal(alpha.Replicas))
Ω(alpha.Path).Should(Equal(""))
Ω(bravo.Path).Should(Equal(path))
})
})