forked from evilmarty/metroplex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_test.go
More file actions
42 lines (34 loc) · 1.01 KB
/
Copy pathclient_test.go
File metadata and controls
42 lines (34 loc) · 1.01 KB
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
package metroplex
import (
"reflect"
"testing"
)
func TestClient_Authorize(t *testing.T) {
key := "X-Plex-Token"
expected := "abc123"
c := newClient().Authorize(expected)
if actual := c.Headers[key]; actual != expected {
t.Errorf("Expected the header %s to be %s, not %s.", key, expected, actual)
}
}
func TestClient_Request(t *testing.T) {
method, url := "POST", "https://www.example.com"
r := newClient().Request(method, url)
if actual := r.Request.Method; actual != method {
t.Errorf("Expected the request method to be %s, not %s", method, actual)
}
if actual := r.Request.URL; actual.String() != url {
t.Errorf("Expected the request url to be %s, not %s", url, actual)
}
for key, val := range DefaultHeaders {
if r.Request.Header.Get(key) != val {
t.Errorf("Expected the request to include the header %s: %s", key, val)
}
}
}
func TestNewClient(t *testing.T) {
c := newClient()
if !reflect.DeepEqual(c.Headers, DefaultHeaders) {
t.Error("Expected the client to have default headers set")
}
}