forked from michaelklishin/rabbit-hole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit_test.go
48 lines (39 loc) · 1.19 KB
/
unit_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
package rabbithole
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Unit tests", func() {
Context("DeleteAfter marshalling", func() {
It("unmarshalls DeleteAfter when it is a number", func() {
var d DeleteAfter
s := []byte("1")
err := d.UnmarshalJSON(s)
Ω(err).ShouldNot(HaveOccurred())
Ω(d).Should(Equal(DeleteAfter("1")))
})
It("unmarshalls DeleteAfter when it is a quoted string", func() {
var d DeleteAfter
s := []byte("\"3\"")
err := d.UnmarshalJSON(s)
Ω(err).ShouldNot(HaveOccurred())
Ω(d).Should(Equal(DeleteAfter("3")))
})
})
Context("URISet marshalling", func() {
It("unmarshalls a single string", func() {
var us URISet
bs := []byte("\"amqp://127.0.0.1:5672\"")
err := us.UnmarshalJSON(bs)
Ω(err).ShouldNot(HaveOccurred())
Ω(us).Should(Equal(URISet([]string{"amqp://127.0.0.1:5672"})))
})
It("unmarshalls a list of strings", func() {
var us URISet
bs := []byte("[\"amqp://127.0.0.1:5672\", \"amqp://localhost:5672\"]")
err := us.UnmarshalJSON(bs)
Ω(err).ShouldNot(HaveOccurred())
Ω(us).Should(Equal(URISet([]string{"amqp://127.0.0.1:5672", "amqp://localhost:5672"})))
})
})
})