-
Notifications
You must be signed in to change notification settings - Fork 63
/
grant_common_test.go
104 lines (100 loc) · 2.21 KB
/
grant_common_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
93
94
95
96
97
98
99
100
101
102
103
104
package pubnub
import (
"github.com/stretchr/testify/assert"
"testing"
)
func Test_toUUIDsPermissionsMap(t *testing.T) {
tests := []struct {
name string
have map[UserId]UserPermissions
want map[string]UUIDPermissions
}{{
name: "Get",
have: map[UserId]UserPermissions{"a": {
Get: true,
}},
want: map[string]UUIDPermissions{"a": {
Get: true,
}}}, {
name: "Update",
have: map[UserId]UserPermissions{"a": {
Update: true,
}},
want: map[string]UUIDPermissions{"a": {
Update: true,
}}}, {
name: "Delete",
have: map[UserId]UserPermissions{"a": {
Delete: true,
}},
want: map[string]UUIDPermissions{"a": {
Delete: true,
}}}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equalf(t, tt.want, toUUIDsPermissionsMap(tt.have), "toUUIDsPermissionsMap(%v)", tt.have)
})
}
}
func Test_toChannelsPermissionsMap(t *testing.T) {
tests := []struct {
name string
have map[SpaceId]SpacePermissions
want map[string]ChannelPermissions
}{{
name: "Get",
have: map[SpaceId]SpacePermissions{"a": {
Get: true,
}},
want: map[string]ChannelPermissions{"a": {
Get: true,
}}}, {
name: "Update",
have: map[SpaceId]SpacePermissions{"a": {
Update: true,
}},
want: map[string]ChannelPermissions{"a": {
Update: true,
}}}, {
name: "Write",
have: map[SpaceId]SpacePermissions{"a": {
Write: true,
}},
want: map[string]ChannelPermissions{"a": {
Write: true,
}}}, {
name: "Delete",
have: map[SpaceId]SpacePermissions{"a": {
Delete: true,
}},
want: map[string]ChannelPermissions{"a": {
Delete: true,
}}}, {
name: "Read",
have: map[SpaceId]SpacePermissions{"a": {
Read: true,
}},
want: map[string]ChannelPermissions{"a": {
Read: true,
}}}, {
name: "Manage",
have: map[SpaceId]SpacePermissions{"a": {
Manage: true,
}},
want: map[string]ChannelPermissions{"a": {
Manage: true,
}}}, {
name: "Join",
have: map[SpaceId]SpacePermissions{"a": {
Join: true,
}},
want: map[string]ChannelPermissions{"a": {
Join: true,
}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equalf(t, tt.want, toChannelsPermissionsMap(tt.have), "toChannelsPermissionsMap(%v)", tt.have)
})
}
}