forked from manyminds/api2go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext_test.go
More file actions
44 lines (38 loc) · 787 Bytes
/
context_test.go
File metadata and controls
44 lines (38 loc) · 787 Bytes
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
package api2go
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Context", func() {
Context("Set", func() {
c := &APIContext{}
It("sets key", func() {
c.Set("test", 1)
_, ok := c.keys["test"]
Expect(ok).To(BeTrue())
})
})
Context("Get", func() {
c := &APIContext{}
c.Set("test", 2)
It("gets key", func() {
key, ok := c.Get("test")
Expect(ok).To(BeTrue())
Expect(key.(int)).To(Equal(2))
})
It("not okay if key does not exist", func() {
key, ok := c.Get("nope")
Expect(ok).To(BeFalse())
Expect(key).To(BeNil())
})
})
Context("Reset", func() {
c := &APIContext{}
c.Set("test", 3)
It("reset removes keys", func() {
c.Reset()
_, ok := c.Get("test")
Expect(ok).To(BeFalse())
})
})
})