forked from grafana/amixr-api-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_group_test.go
61 lines (53 loc) · 1.15 KB
/
user_group_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
package aapi
import (
"fmt"
"net/http"
"reflect"
"testing"
)
var testUserGroup = &UserGroup{
ID: "GPFAPH7J7BKJB",
Type: "slack_based",
SlackUserGroup: &SlackUserGroup{
"TEST_SLACK_ID",
"Test",
"test",
},
}
var testUserGroupBody = `{
"id": "GPFAPH7J7BKJB",
"type": "slack_based",
"slack": {
"id": "TEST_SLACK_ID",
"name": "Test",
"handle": "test"
}
}`
func TestListUserGroups(t *testing.T) {
mux, server, client := setup(t)
defer teardown(server)
mux.HandleFunc("/api/v1/user_groups/", func(w http.ResponseWriter, r *http.Request) {
testRequestMethod(t, r, "GET")
fmt.Fprint(w, fmt.Sprintf(`{"count": 1, "next": null, "previous": null, "results": [%s]}`, testUserGroupBody))
})
options := &ListUserGroupOptions{
SlackHandle: "test",
}
userGroups, _, err := client.UserGroups.ListUserGroups(options)
if err != nil {
t.Fatal(err)
}
want := &PaginatedUserGroupsResponse{
PaginatedResponse: PaginatedResponse{
Count: 1,
Next: nil,
Previous: nil,
},
UserGroups: []*UserGroup{
testUserGroup,
},
}
if !reflect.DeepEqual(want, userGroups) {
t.Errorf("returned\n %+v, \nwant\n %+v", userGroups, want)
}
}