summaryrefslogtreecommitdiff
path: root/bilibili/room_status_test.go
blob: f97cf51ebe5321ecf23e2723d8a4de5ca59bb269 (plain)
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
package bilibili

import (
	"github.com/keuin/slbr/common"
	"github.com/keuin/slbr/logging"
	"log"
	"testing"
)

func TestBilibili_GetRoomPlayInfo(t *testing.T) {
	// get an online live room for testing
	liveList, err := common.GetLiveListForGuestUser()
	if err != nil {
		t.Fatalf("cannot get live list for testing: %v", err)
	}
	lives := liveList.Data.Data
	if len(lives) <= 0 {
		t.Fatalf("no live for guest available")
	}
	roomId := common.RoomId(lives[0].Roomid)

	logger := log.Default()
	bi := NewBilibili(logging.NewWrappedLogger(logger, "test-logger"))
	resp, err := bi.GetRoomPlayInfo(roomId)
	if err != nil {
		t.Fatalf("GetRoomPlayInfo: %v", err)
	}
	if resp.Code != 0 ||
		resp.Message != "0" ||
		resp.Data.UID <= 0 ||
		resp.Data.RoomID != uint64(roomId) ||
		resp.Data.LiveStatus != Streaming {
		t.Fatalf("Invalid GetRoomPlayInfo response: %v", resp)
	}
}