-
Notifications
You must be signed in to change notification settings - Fork 14
/
live_test.go
63 lines (59 loc) · 1.3 KB
/
live_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
package dylive
import (
"context"
"encoding/json"
"os"
"testing"
"time"
)
func TestGetCategories(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
categories, err := GetCategories(ctx)
if err != nil {
t.Error(err)
}
if len(categories) < 1 {
t.Error("categories should not be empty")
}
for _, cat := range categories {
if len(cat.Categories) < 1 {
t.Error("sub category should not be empty")
}
}
if len(categories) > 0 {
e := json.NewEncoder(os.Stdout)
e.SetIndent("", " ")
e.SetEscapeHTML(false)
e.Encode(categories[0:1])
}
}
func TestGetRoomsByCategory(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
rooms, err := GetRoomsByCategory(ctx, "1_2_1_1010045")
if err != nil {
t.Error(err)
}
if len(rooms) < 1 {
t.Error("rooms should not be empty")
}
if len(rooms) > 0 {
e := json.NewEncoder(os.Stdout)
e.SetIndent("", " ")
e.SetEscapeHTML(false)
e.Encode(rooms[0:1])
}
}
func TestGetRoom(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
room, err := GetRoom(ctx, "maidanglaodo")
if err != nil {
t.Error(err)
}
e := json.NewEncoder(os.Stdout)
e.SetIndent("", " ")
e.SetEscapeHTML(false)
e.Encode(room)
}