-
Notifications
You must be signed in to change notification settings - Fork 0
/
callback_test.go
52 lines (46 loc) · 1.19 KB
/
callback_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
package bandwidth
import (
"fmt"
"io/ioutil"
"testing"
)
func TestParseEvent(t *testing.T) {
testCases := map[string]struct {
Filename string
Want interface{}
}{
"answer": {
Filename: "testdata/answer.json",
Want: &AnswerEvent{
EventType: "answer",
AccountId: "55555555",
ApplicationId: "7fc9698a-b04a-468b-9e8f-91238c0d0086",
To: "+15553334444",
From: "+15551112222",
Direction: "outbound",
CallId: "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d",
CallUrl: "https://voice.bandwidth.com/api/v2/accounts/55555555/calls/c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d",
StartTime: "2019-06-20T15:54:22.234Z",
AnswerTime: "2019-06-20T15:54:25.432Z",
Tag: "example-tag",
},
},
}
for label, tc := range testCases {
t.Run(label, func(t *testing.T) {
v := parseEventFile(t, tc.Filename)
fmt.Println(v)
})
}
}
func parseEventFile(t *testing.T, filename string) Event {
data, err := ioutil.ReadFile(filename)
if err != nil {
t.Fatalf("got %v; want nil", err)
}
event, err := ParseEvent(data)
if err != nil {
t.Fatalf("got %v; want nil", err)
}
return event
}