-
Notifications
You must be signed in to change notification settings - Fork 8
/
slack_channel_test.go
49 lines (41 loc) · 1.03 KB
/
slack_channel_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
package aapi
import (
"fmt"
"net/http"
"reflect"
"testing"
)
var testSlackChannel = &SlackChannel{
Name: "general",
SlackId: "TEST_SLACK_ID",
}
var testSlackChannelBody = `{
"name": "general",
"slack_id": "TEST_SLACK_ID"
}`
func TestListSlackChannels(t *testing.T) {
mux, server, client := setup(t)
defer teardown(server)
mux.HandleFunc("/api/v1/slack_channels/", func(w http.ResponseWriter, r *http.Request) {
testRequestMethod(t, r, "GET")
fmt.Fprint(w, fmt.Sprintf(`{"count": 1, "next": null, "previous": null, "results": [%s]}`, testSlackChannelBody))
})
options := &ListSlackChannelOptions{}
slackChannels, _, err := client.SlackChannels.ListSlackChannels(options)
if err != nil {
t.Fatal(err)
}
want := &PaginatedSlackChannelsResponse{
PaginatedResponse: PaginatedResponse{
Count: 1,
Next: nil,
Previous: nil,
},
SlackChannels: []*SlackChannel{
testSlackChannel,
},
}
if !reflect.DeepEqual(want, slackChannels) {
t.Errorf("returned\n %+v, \nwant\n %+v", slackChannels, want)
}
}