forked from atlassian/go-sentry-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents_test.go
92 lines (69 loc) · 1.78 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
88
89
90
91
92
package sentry
import (
"fmt"
"testing"
"github.com/atlassian/go-sentry-api/datatype"
"github.com/getsentry/raven-go"
)
func TestEventsResource(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()
dsnkey, err := client.CreateClientKey(org, project, "testing key")
if err != nil {
t.Fatal(err)
}
ravenClient, err := raven.New(dsnkey.DSN.Secret)
if err != nil {
t.Fatal(err)
}
for i := 0; i < 10; i++ {
ravenClient.CaptureMessageAndWait(fmt.Sprintf("Testing message %d", i), map[string]string{
"server": fmt.Sprintf("%d-app-node", i),
}, &raven.Message{
Message: fmt.Sprintf("Testing some stuff out Brah %d", i),
})
}
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 {
_, 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)
}
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" {
t.Logf("Messages: %v", *inter.(*datatype.Message).Message)
}
}
})
})
}