-
Notifications
You must be signed in to change notification settings - Fork 39
/
bulk_test.go
70 lines (55 loc) · 1.36 KB
/
bulk_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 sentry
import (
"testing"
)
func TestBulkResourceModifyDelete(t *testing.T) {
client := newTestClient(t)
org, err := client.GetOrganization(getDefaultOrg())
if err != nil {
t.Fatal(err)
}
team, cleanup := createTeamHelper(t)
project, cleanupproj := createProjectHelper(t, team)
defer cleanupproj()
defer cleanup()
createMessagesHelper(t, client, org, project, 10)
t.Run("Fetch all messages for project", func(t *testing.T) {
issues, link, err := client.GetIssues(org, project, nil, nil, nil)
if err != nil {
t.Error(err)
}
ids := make([]string, 0)
for _, issue := range issues {
ids = append(ids, *issue.ID)
}
for link.Next.Results {
for _, issue := range issues {
ids = append(ids, *issue.ID)
}
link, err = client.GetPage(link.Next, &issues)
if err != nil {
t.Error(err)
}
}
t.Run("Modify all messages to be resolved", func(t *testing.T) {
resolved := Resolved
resp, err := client.BulkMutateIssues(org, project, IssueBulkRequest{
Status: &resolved,
}, &ids, nil)
if err != nil {
t.Skip(err)
}
if resp.Status != nil {
if *resp.Status != Resolved {
t.Error("Should have made this resolved")
}
}
})
t.Run("Delete all of the messages", func(t *testing.T) {
err := client.BulkDeleteIssues(org, project, ids)
if err != nil {
t.Error(err)
}
})
})
}