forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth_test.go
51 lines (42 loc) · 1.12 KB
/
auth_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
package slack
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func getTeamList(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response := []byte(`{
"ok": true,
"teams": [
{
"name": "Shinichi's workspace",
"id": "T12345678"
},
{
"name": "Migi's workspace",
"id": "T12345679"
}
],
"response_metadata": {
"next_cursor": "dXNlcl9pZDo5MTQyOTI5Mzkz"
}
}`)
rw.Write(response)
}
func TestListTeams(t *testing.T) {
http.HandleFunc("/auth.teams.list", getTeamList)
once.Do(startServer)
api := New("testing-token", OptionAPIURL("http://"+serverAddr+"/"))
teams, cursor, err := api.ListTeams(ListTeamsParameters{})
if err != nil {
t.Errorf("Unexpected error: %s", err)
return
}
assert.Len(t, teams, 2)
assert.Equal(t, "T12345678", teams[0].ID)
assert.Equal(t, "Shinichi's workspace", teams[0].Name)
assert.Equal(t, "T12345679", teams[1].ID)
assert.Equal(t, "Migi's workspace", teams[1].Name)
assert.Equal(t, "dXNlcl9pZDo5MTQyOTI5Mzkz", cursor)
}