forked from lokalise/go-lokalise-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvc_permissiontemplates_test.go
88 lines (81 loc) · 2.03 KB
/
svc_permissiontemplates_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
package lokalise
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestTeamPermissionTemplates_List(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc(
"/teams/1/roles",
func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
testMethod(t, r, "GET")
testHeader(t, r, apiTokenHeader, testApiToken)
_, _ = fmt.Fprint(w, `{
"roles": [
{
"id": 1,
"role": "Localisation management",
"permissions": [
"activity",
"branches_main_modify"
],
"description": "Manage project settings, contributors and tasks",
"tag": "Full access",
"tagColor": "green",
"doesEnableAllReadOnlyLanguages": true
},
{
"id": 2,
"role": "Developer",
"permissions": [
"download",
"upload"
],
"description": "Create keys, upload and download content",
"tag": "Advanced",
"tagColor": "cyan",
"doesEnableAllReadOnlyLanguages": true
}
]
}`)
})
r, err := client.PermissionTemplates().ListPermissionRoles(1)
if err != nil {
t.Errorf("Teams.List returned error: %v", err)
}
want := PermissionRoleResponse{
Roles: []PermissionTemplate{
{
ID: 1,
Role: "Localisation management",
Permissions: []string{
"activity",
"branches_main_modify",
},
Description: "Manage project settings, contributors and tasks",
Tag: "Full access",
TagColor: "green",
DoesEnableAllReadOnlyLanguages: true,
},
{
ID: 2,
Role: "Developer",
Permissions: []string{
"download",
"upload",
},
Description: "Create keys, upload and download content",
Tag: "Advanced",
TagColor: "cyan",
DoesEnableAllReadOnlyLanguages: true,
},
},
}
if !reflect.DeepEqual(r, want) {
t.Errorf("Team.PermissionRoles.List returned %+v, want %+v", r, want)
}
}