forked from toorop/go-bitcoind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers_test.go
56 lines (49 loc) · 1.12 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
package bitcoind
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 := make(map[string]interface{})
rpcError["code"] = 6.32
rpcError["message"] = "Fake error"
response := rpcResponse{
Id: 1212,
Result: []byte("{}"),
Err: rpcError,
}
It("should occur", func() {
err := handleError(nil, &response)
Expect(Ω(err).Should(HaveOccurred()))
})
})
})
})