forked from GetStream/stream-chat-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel_type_test.go
46 lines (33 loc) · 1 KB
/
channel_type_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
package stream_chat // nolint: golint
import (
"testing"
"github.com/stretchr/testify/assert"
)
func prepareChannelType(t *testing.T, c *Client) *ChannelType {
ct := NewChannelType(randomString(10))
ct, err := c.CreateChannelType(ct)
mustNoError(t, err, "create channel type")
return ct
}
func TestClient_GetChannelType(t *testing.T) {
c := initClient(t)
ct := prepareChannelType(t, c)
defer func() {
mustNoError(t, c.DeleteChannelType(ct.Name), "delete channel type")
}()
got, err := c.GetChannelType(ct.Name)
mustNoError(t, err, "get channel type")
assert.Equal(t, ct.Name, got.Name)
assert.Equal(t, len(ct.Commands), len(got.Commands))
assert.Equal(t, ct.Permissions, got.Permissions)
}
func TestClient_ListChannelTypes(t *testing.T) {
c := initClient(t)
ct := prepareChannelType(t, c)
defer func() {
mustNoError(t, c.DeleteChannelType(ct.Name), "delete channel type")
}()
got, err := c.ListChannelTypes()
mustNoError(t, err, "list channel types")
assert.Contains(t, got, ct.Name)
}