-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrpc_client_test.go
56 lines (42 loc) · 1.43 KB
/
grpc_client_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
package main
import (
"os"
"testing"
)
// TODO: Figure out a way to pull a definitely active Twitch stream for a 200 test
func TestGetStreamTwitch404(t *testing.T) {
// would be good to actually return a status code
// from getStream so that we can actually
// match to the status code when testing
os.Setenv("STREAMDL_GRPC_ADDR", "localhost")
defer os.Unsetenv("STREAMDL_GRPC_ADDR")
os.Setenv("STREAMDL_GRPC_PORT", "50051")
defer os.Unsetenv("STREAMDL_GRPC_PORT")
url, _ := getStream("twitch.tv", "ANonExistentUser", "best")
if url != "" {
t.Errorf("Test should have not received an URL, got %s", url)
}
}
func TestGetStreamYouTube404(t *testing.T) {
os.Setenv("STREAMDL_GRPC_ADDR", "localhost")
defer os.Unsetenv("STREAMDL_GRPC_ADDR")
os.Setenv("STREAMDL_GRPC_PORT", "50051")
defer os.Unsetenv("STREAMDL_GRPC_PORT")
url, _ := getStream("youtube.com", "ANonExistentUser1234", "best")
if url != "" {
t.Errorf("Test should have not received an URL, got %s", url)
}
}
func TestGetStreamKick404(t *testing.T) {
// Kick is not actually yet supported
// But it follows the Twitch style
// site/channel naming format
os.Setenv("STREAMDL_GRPC_ADDR", "localhost")
defer os.Unsetenv("STREAMDL_GRPC_ADDR")
os.Setenv("STREAMDL_GRPC_PORT", "50051")
defer os.Unsetenv("STREAMDL_GRPC_PORT")
url, _ := getStream("kick.com", "ANonExistentUser", "best")
if url != "" {
t.Errorf("Test should have not received an URL, got %s", url)
}
}