forked from gavv/httpexpect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
printer_test.go
44 lines (33 loc) · 1.03 KB
/
printer_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
package httpexpect
import (
"bytes"
"io/ioutil"
"net/http"
"testing"
)
func TestCompactPrinter(t *testing.T) {
printer := NewCompactPrinter(t)
body1 := bytes.NewBufferString("body1")
body2 := bytes.NewBufferString("body2")
req1, _ := http.NewRequest("GET", "http://example.com", body1)
req2, _ := http.NewRequest("GET", "http://example.com", nil)
printer.Request(req1)
printer.Request(req2)
printer.Request(nil)
printer.Response(&http.Response{Body: ioutil.NopCloser(body2)}, 0)
printer.Response(&http.Response{}, 0)
printer.Response(nil, 0)
}
func TestDebugPrinter(t *testing.T) {
printer := NewDebugPrinter(t, true)
body1 := bytes.NewBufferString("body1")
body2 := bytes.NewBufferString("body2")
req1, _ := http.NewRequest("GET", "http://example.com", body1)
req2, _ := http.NewRequest("GET", "http://example.com", nil)
printer.Request(req1)
printer.Request(req2)
printer.Request(nil)
printer.Response(&http.Response{Body: ioutil.NopCloser(body2)}, 0)
printer.Response(&http.Response{}, 0)
printer.Response(nil, 0)
}