-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrc_test.go
84 lines (70 loc) · 1.55 KB
/
rc_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
package rc
import (
"testing"
"github.com/davecgh/go-spew/spew"
)
func clientOpts() []ClientOption {
return []ClientOption{
ServerURL("http://localhost:3000"),
CredFromJson("./token.json"),
//Debug(true),
StreamOptions(
EventSubscription(SubNotifyAll, NotifyRolesChange),
),
}
}
func createTestClient() *Client {
opts := clientOpts()
return New(opts...)
}
func TestNew(t *testing.T) {
client := createTestClient()
if err := client.Connect(); err != nil {
t.Error(err)
}
tests := []struct {
name string
}{
{
name: "testrc",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := client.c.getInfo()
if result.Error() != nil {
t.Errorf("info request failed: %v", result.Error())
}
defer client.log.Sync()
client.log.Infow("string result: "+result.String(),
"code", result.StatusCode(),
)
v := make(map[string]interface{})
if err := result.JSON(&v); err != nil {
t.Errorf("error getting result json: %v", err)
}
rooms, err := client.GetSubscriptions()
if err != nil {
t.Errorf("error getting rooms: %v", err)
}
for _, r := range rooms {
if r.Name == "" {
spew.Dump(r)
} else {
client.log.Infow(r.Name, "id", r.RoomID, "type", r.Type)
}
}
/*
_, err = client.GetRoomByName("general")
if err != nil {
t.Errorf("error getting room general: %v", err)
}
//spew.Dump(room)
users, err := client.GetUsers()
if err != nil {
t.Errorf("error getting users: %v", err)
}
spew.Dump(users) */
})
}
}