-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmemory_test.go
34 lines (32 loc) · 876 Bytes
/
memory_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
package gonfig_test
import (
. "github.com/Nomon/gonfig"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("MemoryConfig", func() {
var cfg Configurable
BeforeEach(func() {
cfg = NewMemoryConfig()
})
It("Should be able to store and retrieve data", func() {
cfg.Set("test", "abc")
Expect(cfg.Get("test")).To(Equal("abc"))
})
It("Should Reset() to zero length All()", func() {
cfg.Set("test", "abc")
Expect(cfg.Get("test")).To(Equal("abc"))
Expect(len(cfg.All())).To(Equal(1))
cfg.Reset()
Expect(len(cfg.All())).To(Equal(0))
})
It("Should Reset() with data correctly", func() {
cfg.Set("test", "abc")
cfg.Set("test_abc", "123")
Expect(cfg.Get("test")).To(Equal("abc"))
Expect(len(cfg.All())).To(Equal(2))
cfg2 := NewMemoryConfig()
cfg2.Reset(cfg.All())
Expect(cfg.Get("test")).To(Equal(cfg2.Get("test")))
})
})