mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-26 02:09:47 +08:00
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)
|
||
|
}
|
||
|
}
|
||
|
}
|