-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscope_enum_test.go
More file actions
48 lines (42 loc) · 1.43 KB
/
scope_enum_test.go
File metadata and controls
48 lines (42 loc) · 1.43 KB
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
package gokick_test
import (
"fmt"
"testing"
"github.com/scorfly/gokick"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewScopeError(t *testing.T) {
testCases := map[string]string{
"empty": "",
"not supported": "not supported",
}
for name, value := range testCases {
t.Run(name, func(t *testing.T) {
_, err := gokick.NewScope(value)
assert.EqualError(t, err, fmt.Sprintf("unknown scope: %s", value))
})
}
}
func TestNewScopeSuccess(t *testing.T) {
testCases := map[string]gokick.Scope{
"user:read": gokick.ScopeUserRead,
"channel:read": gokick.ScopeChannelRead,
"channel:write": gokick.ScopeChannelWrite,
"channel:rewards:read": gokick.ScopeChannelRewardsRead,
"channel:rewards:write": gokick.ScopeChannelRewardsWrite,
"chat:write": gokick.ScopeChatWrite,
"streamkey:read": gokick.ScopeStreamkeyRead,
"events:subscribe": gokick.ScopeEventSubscribe,
"moderation:ban": gokick.ScopeModerationBan,
"moderation:chat_message:manage": gokick.ScopeModerationChatMessageManage,
"kicks:read": gokick.ScopeKicksRead,
}
for name, value := range testCases {
t.Run(name, func(t *testing.T) {
Scope, err := gokick.NewScope(value.String())
require.NoError(t, err)
assert.Equal(t, Scope, value)
})
}
}