forked from kevinburke/twilio-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task_router_activity_test.go
67 lines (58 loc) · 1.81 KB
/
task_router_activity_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
package twilio
import (
"context"
"net/url"
"testing"
"github.com/kevinburke/twilio-go/testdata"
)
func TestGetActivity(t *testing.T) {
t.Parallel()
client, server := getServer(testdata.TaskRouterActivityResponse)
defer server.Close()
workspaceSid := "WS58f1e8f2b1c6b88ca90a012a4be0c279"
sid := "WAc74e6c39eb3080f8211d049a8b95611c"
name := "NewAvailableActivity"
activity, err := client.TaskRouter.Workspace(workspaceSid).Activities.Get(context.Background(), sid)
if err != nil {
t.Fatal(err)
}
if activity.Sid != sid {
t.Errorf("activity: got sid %q, want %q", activity.Sid, sid)
}
if activity.FriendlyName != name {
t.Errorf("activity: got sid %q, want %q", activity.FriendlyName, name)
}
if len(server.URLs) != 1 {
t.Errorf("URL length is %d, want 1", len(server.URLs))
}
want := "/v1/Workspaces/" + workspaceSid + "/Activities/" + sid
if server.URLs[0].String() != want {
t.Errorf("request URL:\ngot %q\nwant %q", server.URLs[0], want)
}
}
func TestCreateActivity(t *testing.T) {
t.Parallel()
client, server := getServer(testdata.TaskRouterActivityCreateResponse)
defer server.Close()
data := url.Values{}
newname := "Some Activity"
data.Set("FriendlyName", newname)
workspaceSid := "WS7a2aa7d8acc191786ad3c647c5fc3110"
act, err := client.TaskRouter.Workspace(workspaceSid).Activities.Create(context.Background(), data)
if err != nil {
t.Fatal(err)
}
if act.WorkspaceSid != workspaceSid {
t.Errorf("WorkspaceSid not correct")
}
if act.FriendlyName != "twilio-go-activity-client-testing" {
t.Errorf("FriendlyNames don't match")
}
if len(server.URLs) != 1 {
t.Errorf("URL length is %d, want 1", len(server.URLs))
}
want := "/v1/Workspaces/" + workspaceSid + "/Activities"
if server.URLs[0].String() != want {
t.Errorf("request URL:\ngot %q\nwant %q", server.URLs[0], want)
}
}