-
Notifications
You must be signed in to change notification settings - Fork 39
/
events_test.go
87 lines (63 loc) · 1.61 KB
/
events_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
package sentry
import (
"testing"
"github.com/atlassian/go-sentry-api/datatype"
)
func TestEventsResource(t *testing.T) {
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()
createMessagesHelper(t, client, org, project, 10)
issues, _, err := client.GetIssues(org, project, nil, nil, nil)
if err != nil {
t.Fatal(err)
}
if len(issues) == 0 {
t.Fatalf("no issues found for project %s", project.Name)
}
t.Run("Read out all events for a issue", func(t *testing.T) {
for _, issue := range issues {
t.Logf("Issue: %s", *issue.ID)
_, err = client.GetLatestEvent(issue)
if err != nil {
t.Error(err)
}
_, err = client.GetOldestEvent(issue)
if err != nil {
t.Error(err)
}
}
t.Run("Convert all entries to proper types if we can", func(t *testing.T) {
oldest, err := client.GetOldestEvent(issues[0])
if err != nil {
t.Error(err)
}
if len(oldest.Entries) == 0 {
t.Fatal("no entries found and is nil")
}
for _, entry := range oldest.Entries {
name, inter, err := entry.GetInterface()
if err != nil {
t.Error(err)
}
t.Logf("Name: %s, Interface: %v, Error: %v", name, inter, err)
if name == "message" {
if inter == nil {
t.Error("iter message is nil")
}
if m := inter.(*datatype.Message); m != nil {
t.Logf("Messages: %v", m.Message)
} else {
t.Errorf("Message is nil %v", m)
}
}
}
})
})
}