forked from plivo/plivo-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phlos_test.go
86 lines (71 loc) · 2.09 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
package plivo
import (
"errors"
"testing"
)
func TestPhlo_Get(t *testing.T) {
expectResponse("PhloGetResoponse.json", 200)
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)
assertPhloRequest(t, "GET", "phlo/%s", testPhloId)
}
func TestNode_Get(t *testing.T) {
expectResponse("NodeGetResponse.json", 200)
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)
assertPhloRequest(t, "GET", "phlo/%s/%s/%s", phloGet.PhloId, nodeType, testNodeId)
}
func TestMultiPartyCall_Get(t *testing.T) {
expectResponse("MultiPartyCallResponse.json", 200)
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)
assertPhloRequest(t, "GET", "phlo/%s/%s/%s", phloGet.PhloId, nodeType, testNodeId)
}
func TestPhloRun_Post(t *testing.T) {
expectResponse("PhloRunResponse.json", 200)
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)
assertPhloRequest(t, "POST", "account/%s/phlo/%s/", phloClient.AuthId, phloGet.PhloId)
}