forked from grafana/grafana-api-golang-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
team_external_group_test.go
70 lines (58 loc) · 1.2 KB
/
team_external_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
62
63
64
65
66
67
68
69
70
package gapi
import (
"testing"
"github.com/gobs/pretty"
)
const (
getTeamGroupsJSON = `
[
{
"orgId": 1,
"teamId": 1,
"groupId": "test"
}
]
`
createdTeamGroupJSON = `
{
"message":"Group added to Team"
}
`
deletedTeamGroupJSON = `
{
"message":"Team Group removed"
}
`
)
func TestTeamGroups(t *testing.T) {
server, client := gapiTestTools(t, 200, getTeamGroupsJSON)
defer server.Close()
teamID := int64(1)
teamGroups, err := client.TeamGroups(teamID)
if err != nil {
t.Fatal(err)
}
t.Log(pretty.PrettyFormat(teamGroups))
if len(teamGroups) != 1 {
t.Error("Length of returned teamGroups should be 1")
}
if teamGroups[0].TeamID != 1 || teamGroups[0].OrgID != 1 || teamGroups[0].GroupID != "test" {
t.Error("Not correctly parsing returned teamGroups.")
}
}
func TestNewTeamGroup(t *testing.T) {
server, client := gapiTestTools(t, 200, createdTeamGroupJSON)
defer server.Close()
err := client.NewTeamGroup(int64(1), "test")
if err != nil {
t.Fatal(err)
}
}
func TestDeleteTeamGroup(t *testing.T) {
server, client := gapiTestTools(t, 200, deletedTeamGroupJSON)
defer server.Close()
err := client.DeleteTeamGroup(int64(1), "test")
if err != nil {
t.Fatal(err)
}
}