-
Notifications
You must be signed in to change notification settings - Fork 1
/
wredis_test.go
46 lines (37 loc) · 1.03 KB
/
wredis_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
package wredis_test
import (
. "github.com/crowdriff/wredis"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Wredis", func() {
var pool *Wredis
var err error
AfterEach(func() {
if pool != nil {
Ω(pool.Close()).Should(Succeed())
}
pool = nil
})
It("Should create a new default pool", func() {
pool, err = NewDefaultPool()
Ω(err).ShouldNot(HaveOccurred())
Ω(pool).ShouldNot(BeNil())
})
It("Should fail to create a new pool given an empty host", func() {
_, err = NewPool("", 6379, 0)
Ω(err).Should(HaveOccurred())
Ω(err.Error()).Should(Equal("host cannot be empty"))
})
It("Should fail to create a new pool given an invalid port", func() {
_, err = NewPool("localhost", 0, 0)
Ω(err).Should(HaveOccurred())
Ω(err.Error()).Should(Equal("port cannot be 0"))
})
It("Should create an unsafe pool successfully", func() {
pool, err = NewUnsafe("localhost", 6379, 0)
Ω(err).ShouldNot(HaveOccurred())
Ω(pool).ShouldNot(BeNil())
Ω(pool.FlushAll()).Should(Succeed())
})
})