forked from atlassian/go-sentry-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
team_test.go
102 lines (86 loc) · 2.19 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package sentry
import (
"testing"
)
func createTeamHelper(t *testing.T) (Team, func() error) {
client := newTestClient(t)
org, err := client.GetOrganization(getDefaultOrg())
if err != nil {
t.Fatal(err)
}
team, err := client.CreateTeam(org, generateIdentifier("team"), nil)
if err != nil {
t.Fatal(err)
}
return team, func() error {
return client.DeleteTeam(org, team)
}
}
func TestTeamResource(t *testing.T) {
t.Parallel()
client := newTestClient(t)
org, err := client.GetOrganization(getDefaultOrg())
if err != nil {
t.Fatal(err)
}
team, err := client.CreateTeam(org, "Test team for Go Client", nil)
if err != nil {
t.Fatal(err)
}
t.Run("Verify team creation", func(t *testing.T) {
if team.Name != "Test team for Go Client" {
t.Error("Team name is not correct")
}
})
t.Run("Fetch the team", func(t *testing.T) {
team, err := client.GetTeam(org, *team.Slug)
if err != nil {
t.Error(err)
}
if team.Name != "Test team for Go Client" {
t.Error("Failed to fetch team on server side")
}
})
t.Run("Update the team name", func(t *testing.T) {
team.Name = "Updated team name for testing"
err := client.UpdateTeam(org, team)
if err != nil {
t.Error(err)
}
if team.Name != "Updated team name for testing" {
t.Error("Failed to update team on server side")
}
})
t.Run("Create new project for team", func(t *testing.T) {
if proj, err := client.CreateProject(org, team, "Python test project", nil); err != nil {
t.Error(err)
} else {
if proj.Name != "Python test project" {
t.Error("Project name does not match")
}
t.Run("Delete project for org", func(t *testing.T) {
err := client.DeleteProject(org, proj)
if err != nil {
t.Error(err)
}
})
}
})
t.Run("Get all projects for this team", func(t *testing.T) {
newproject, err := client.CreateProject(org, team, "Example project for sentry", nil)
if err != nil {
t.Fatal(err)
}
projects, err := client.GetTeamProjects(org, team)
if err != nil {
t.Error(err)
}
first := projects[0]
if first.Name != newproject.Name {
t.Error("First project in list not project created")
}
})
if err := client.DeleteTeam(org, team); err != nil {
t.Fatal(err)
}
}