forked from dilutedev/doppler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_accounts_test.go
76 lines (64 loc) · 1.86 KB
/
service_accounts_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
package doppler
import (
"testing"
"github.com/stretchr/testify/assert"
)
var (
serviceAccountSlug = "78bf254d-889d-4c43-b68a-034fa67230ef"
newServiceAccountSlug = ""
)
func TestListServiceAccounts(t *testing.T) {
dp, err := NewFromEnv()
assert.Nil(t, err)
assert.NotNil(t, dp)
serviceAccounts, err := dp.ListServiceAccounts(&test_page, &test_limit)
assert.Nil(t, err)
assert.NotNil(t, serviceAccounts)
assert.IsType(t, &ServiceAccounts{}, serviceAccounts)
}
func TestCreateServiceAccount(t *testing.T) {
dp, err := NewFromEnv()
assert.Nil(t, err)
assert.NotNil(t, dp)
serviceAccount, err := dp.CreateServiceAccount(ServiceAccountBodyParams{
Name: "testSlug",
WorkplaceRole: WorkplaceRoleObject{
Identifier: "admin",
},
})
assert.Nil(t, err)
assert.NotNil(t, serviceAccount)
assert.IsType(t, &ServiceAccountModel{}, serviceAccount)
newServiceAccountSlug = serviceAccount.ServiceAccount.Slug
}
func TestRetrieveServiceAccount(t *testing.T) {
dp, err := NewFromEnv()
assert.Nil(t, err)
assert.NotNil(t, dp)
serviceAccount, err := dp.RetrieveServiceAccount(serviceAccountSlug)
assert.Nil(t, err)
assert.NotNil(t, serviceAccount)
assert.IsType(t, &ServiceAccountModel{}, serviceAccount)
}
func TestUpdateServiceAccount(t *testing.T) {
dp, err := NewFromEnv()
assert.Nil(t, err)
assert.NotNil(t, dp)
serviceAccount, err := dp.UpdateServiceAccount(newServiceAccountSlug, ServiceAccountBodyParams{
Name: "testSlugUpdate",
WorkplaceRole: WorkplaceRoleObject{
Identifier: "collaborator",
},
})
assert.Nil(t, err)
assert.NotNil(t, serviceAccount)
assert.IsType(t, &ServiceAccountModel{}, serviceAccount)
}
func TestDeleteServiceAccount(t *testing.T) {
dp, err := NewFromEnv()
assert.Nil(t, err)
assert.NotNil(t, dp)
serviceAccount, err := dp.DeleteServiceAccount(newServiceAccountSlug)
assert.Nil(t, err)
assert.NotNil(t, serviceAccount)
}