forked from grafana/amixr-api-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
team_test.go
55 lines (47 loc) · 1.06 KB
/
team_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
package aapi
import (
"fmt"
"net/http"
"reflect"
"testing"
)
var testTeam = &Team{
ID: "T3HRAP3K3IKOP",
Name: "test team",
Email: "test@test",
AvatarUrl: "https://example.com/avatar",
}
var testTeamBody = `{
"id": "T3HRAP3K3IKOP",
"name": "test team",
"email": "test@test",
"avatar_url": "https://example.com/avatar"
}`
func TestListTeams(t *testing.T) {
mux, server, client := setup(t)
defer teardown(server)
mux.HandleFunc("/api/v1/teams/", func(w http.ResponseWriter, r *http.Request) {
testRequestMethod(t, r, "GET")
fmt.Fprint(w, fmt.Sprintf(`{"count": 1, "next": null, "previous": null, "results": [%s]}`, testTeamBody))
})
options := &ListTeamOptions{
Name: "test team",
}
teams, _, err := client.Teams.ListTeams(options)
if err != nil {
t.Fatal(err)
}
want := &PaginatedTeamsResponse{
PaginatedResponse: PaginatedResponse{
Count: 1,
Next: nil,
Previous: nil,
},
Teams: []*Team{
testTeam,
},
}
if !reflect.DeepEqual(want, teams) {
t.Errorf("returned\n %+v, \nwant\n %+v", teams, want)
}
}