-
Notifications
You must be signed in to change notification settings - Fork 8
/
client_test.go
34 lines (30 loc) · 878 Bytes
/
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
package gobayeux
import "testing"
func TestNewClient(t *testing.T) {
testCases := []struct {
name string
serverAddress string
shouldErr bool
}{
{"valid url for server address", "https://example.com", false},
{"invalid url for server address", "http://192.168.0.%31/", true},
}
for _, testCase := range testCases {
tc := testCase
t.Run(tc.name, func(t *testing.T) {
_, err := NewClient(tc.serverAddress)
if err != nil && !tc.shouldErr {
t.Errorf("expected NewClient() to not return an err but it did, %q", err)
} else if tc.shouldErr && err == nil {
t.Error("expected NewClient() to err but it didn't")
}
})
}
}
func TestSubscribe(t *testing.T) {
client, err := NewClient("https://example.com", nil)
if err != nil {
t.Fatalf("expected a working client but got an err %q", err)
}
client.Subscribe("/foo/bar", nil)
}