mirror of
https://github.com/joohoi/acme-dns.git
synced 2025-07-28 13:47:44 +07:00
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
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)
|
|
}
|