-
Notifications
You must be signed in to change notification settings - Fork 23
/
phlos_test.go
96 lines (80 loc) · 2.3 KB
/
phlos_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package plivo
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
)
func TestPhlo_Get(t *testing.T) {
expectResponse("PhloGetResoponse.json", 200)
assert := require.New(t)
testPhloId := "PhloId"
_, err := phloClient.Phlos.Get("")
if err == nil {
panic(errors.New("error expected"))
}
cl := phloClient.httpClient
phloClient.httpClient = nil
_, err = phloClient.Phlos.Get(testPhloId)
if err == nil {
phloClient.httpClient = cl
panic(errors.New("error expected"))
}
phloClient.httpClient = cl
_, err = phloClient.Phlos.Get(testPhloId)
assert.Nil(err)
assertPhloRequest(t, "GET", "phlo/%s", testPhloId)
}
func TestNode_Get(t *testing.T) {
expectResponse("NodeGetResponse.json", 200)
assert := require.New(t)
testPhloId := "PhloId"
testNodeId := "NodeId"
phloGet, _ := phloClient.Phlos.Get(testPhloId)
cl := phloClient.httpClient
phloClient.httpClient = nil
_, err := phloGet.Node(testNodeId)
if err == nil {
phloClient.httpClient = cl
panic(errors.New("error expected"))
}
phloClient.httpClient = cl
_, err = phloGet.Node(testNodeId)
assert.Nil(err)
assertPhloRequest(t, "GET", "phlo/%s/%s/%s", phloGet.PhloId, nodeType, testNodeId)
}
func TestMultiPartyCall_Get(t *testing.T) {
expectResponse("MultiPartyCallResponse.json", 200)
assert := require.New(t)
testPhloId := "PhloId"
testNodeId := "NodeId"
phloGet, _ := phloClient.Phlos.Get(testPhloId)
cl := phloClient.httpClient
phloClient.httpClient = nil
_, err := phloGet.MultiPartyCall(testNodeId)
if err == nil {
phloClient.httpClient = cl
panic(errors.New("error expected"))
}
phloClient.httpClient = cl
_, err = phloGet.MultiPartyCall(testNodeId)
assert.Nil(err)
assertPhloRequest(t, "GET", "phlo/%s/%s/%s", phloGet.PhloId, nodeType, testNodeId)
}
func TestPhloRun_Post(t *testing.T) {
expectResponse("PhloRunResponse.json", 200)
assert := require.New(t)
testPhloId := "PhloId"
phloGet, _ := phloClient.Phlos.Get(testPhloId)
cl := phloClient.httpClient
phloClient.httpClient = nil
//expectResponse("PhloRunResponse.json", 200)
_, err := phloGet.Run(nil)
if err == nil {
phloClient.httpClient = cl
panic(errors.New("error expected"))
}
phloClient.httpClient = cl
_, err = phloGet.Run(nil)
assert.Nil(err)
assertPhloRequest(t, "POST", "account/%s/phlo/%s/", phloClient.AuthId, phloGet.PhloId)
}