mirror of https://github.com/caddyserver/caddy.git
31 lines
555 B
Go
31 lines
555 B
Go
|
package reverseproxy
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"strings"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestHandlerCopyResponse(t *testing.T) {
|
||
|
h := Handler{}
|
||
|
testdata := []string{
|
||
|
"",
|
||
|
strings.Repeat("a", defaultBufferSize),
|
||
|
strings.Repeat("123456789 123456789 123456789 12", 3000),
|
||
|
}
|
||
|
dst := bytes.NewBuffer(nil)
|
||
|
|
||
|
for _, d := range testdata {
|
||
|
src := bytes.NewBuffer([]byte(d))
|
||
|
dst.Reset()
|
||
|
err := h.copyResponse(dst, src, 0)
|
||
|
if err != nil {
|
||
|
t.Errorf("failed with error: %v", err)
|
||
|
}
|
||
|
out := dst.String()
|
||
|
if out != d {
|
||
|
t.Errorf("bad read: got %q", out)
|
||
|
}
|
||
|
}
|
||
|
}
|