-
Notifications
You must be signed in to change notification settings - Fork 39
/
project_test.go
62 lines (51 loc) · 1.28 KB
/
project_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
package sentry
import (
"testing"
)
func createProjectHelper(t *testing.T, team Team) (Project, func() error) {
client := newTestClient(t)
org, err := client.GetOrganization(getDefaultOrg())
if err != nil {
t.Fatal(err)
}
project, err := client.CreateProject(org, team, generateIdentifier("project"), nil)
if err != nil {
t.Fatal(err)
}
return project, func() error {
return client.DeleteProject(org, project)
}
}
func TestProjectResource(t *testing.T) {
t.Parallel()
client := newTestClient(t)
org, err := client.GetOrganization(getDefaultOrg())
if err != nil {
t.Fatal(err)
}
team, cleanup := createTeamHelper(t)
defer cleanup()
project, cleanupproj := createProjectHelper(t, team)
defer cleanupproj()
t.Run("Fetch project from endpoint", func(t *testing.T) {
endpointproject, err := client.GetProject(org, *project.Slug)
if err != nil {
t.Error(err)
}
if endpointproject.Team.Name != team.Name {
t.Error("Project fetch didnt have the right team name")
}
})
t.Run("Fetch all projects", func(t *testing.T) {
projects, _, err := client.GetProjects()
if err != nil {
t.Error(err)
}
if len(projects) <= 0 {
t.Error("Should have at least on project but got 0")
}
})
if err := client.DeleteTeam(org, team); err != nil {
t.Error(err)
}
}