forked from evilmarty/metroplex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest_test.go
More file actions
37 lines (31 loc) · 798 Bytes
/
Copy pathrequest_test.go
File metadata and controls
37 lines (31 loc) · 798 Bytes
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
package metroplex
import (
"net/http"
"testing"
)
func TestRequest_Headers(t *testing.T) {
cases := map[string]string{
"X-Foo": "foo",
"X-Bar": "bar",
}
r := newRequest("GET", "https://www.example.com")
r = r.Headers(cases)
for c, expected := range cases {
if r.Request.Header.Get(c) != expected {
t.Errorf("Expected the request header %s: %s", c, expected)
}
}
}
func TestRequest_BasicAuth(t *testing.T) {
r := newRequest("GET", "https://www.example.com")
r = r.BasicAuth("chuck", "nope")
if r.Request.Header.Get("Authorization") == "" {
t.Errorf("Expected the authorization header to be set")
}
}
func TestRequest_RespondWith(t *testing.T) {
r := newRequest("GET", "https://www.example.com").RespondWith(http.StatusOK)
if r.Error != nil {
t.Error(r.Error)
}
}