-
Notifications
You must be signed in to change notification settings - Fork 39
/
release_test.go
81 lines (68 loc) · 1.66 KB
/
release_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
package sentry
import (
"testing"
)
func TestReleaseResource(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("Create a new release", func(t *testing.T) {
newrelease := NewRelease{
Version: "abcdefgh123456",
}
rel, relerr := client.CreateRelease(org, project, newrelease)
if relerr != nil {
t.Error(err)
}
if rel.Version != "abcdefgh123456" {
t.Error("version does not match expected")
}
t.Run("Update the release ref", func(t *testing.T) {
ref := "123456123"
rel.Ref = &ref
updateerr := client.UpdateRelease(org, project, rel)
if updateerr != nil {
t.Error(updateerr)
}
if rel.Ref != &ref {
t.Error("Ref did not get updated")
}
t.Run("Delete the release", func(t *testing.T) {
delerr := client.DeleteRelease(org, project, rel)
if delerr != nil {
t.Error(err)
}
})
})
})
t.Run("Fetch all releases for a project", func(t *testing.T) {
newrelease := NewRelease{
Version: "abcdefgh123456",
}
_, relerr := client.CreateRelease(org, project, newrelease)
if relerr != nil {
t.Error(err)
}
releases, _, relserr := client.GetReleases(org, project)
if relserr != nil {
t.Error(relserr)
}
if len(releases) == 0 {
t.Error("Should be at least one release")
}
})
delprojerr := client.DeleteProject(org, project)
if delprojerr != nil {
t.Fatal(delprojerr)
}
if delteam := client.DeleteTeam(org, team); delteam != nil {
t.Error(delteam)
}
}