forked from atlassian/go-sentry-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeys_test.go
60 lines (49 loc) · 1.24 KB
/
keys_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
package sentry
import (
"testing"
)
func TestKeysResource(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 key for project", func(t *testing.T) {
key, err := client.CreateClientKey(org, project, "Test client key")
if err != nil {
t.Error(err)
}
if key.Label != "Test client key" {
t.Error("Key does not have correct label")
}
t.Run("List client keys", func(t *testing.T) {
keys, err := client.GetClientKeys(org, project)
if err != nil {
t.Error(err)
}
if len(keys) != 2 {
t.Errorf("Expected 2 keys, got %d", len(keys))
}
})
t.Run("Update name of client key", func(t *testing.T) {
key, err = client.UpdateClientKey(org, project, key, "This is a new name")
if err != nil {
t.Error(err)
}
if key.Label != "This is a new name" {
t.Error("Failed to update to a new name")
}
t.Run("Deleting the client key", func(t *testing.T) {
err := client.DeleteClientKey(org, project, key)
if err != nil {
t.Error(err)
}
})
})
})
}