forked from naftalimurgor/go-bgld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers_test.go
57 lines (50 loc) · 1.08 KB
/
helpers_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
package bgld
import (
//. "github.com/Toorop/go-bitcoind"
"errors"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Helpers", func() {
Describe("Parse errors", func() {
Context("No error", func() {
response := rpcResponse{
Id: 1212,
Result: []byte("{}"),
Err: nil,
}
It("should return nil", func() {
Expect(handleError(nil, &response)).To(BeNil())
})
})
// err
Context("errPrev is not nil", func() {
errPrev := errors.New("fake error")
response := rpcResponse{
Id: 1212,
Result: []byte("{}"),
Err: nil,
}
It("should occur", func() {
err := handleError(errPrev, &response)
Expect(Ω(err).Should(HaveOccurred()))
})
})
// RPC error is not null
Context("RPC error", func() {
rpcError := &RPCError{
Code: 6,
Message: "Fake error",
}
response := rpcResponse{
Id: 1212,
Result: []byte("{}"),
Err: rpcError,
}
It("should occur", func() {
err := handleError(nil, &response)
Expect(Ω(err).Should(HaveOccurred()))
})
})
})
})