This commit is contained in:
parent
0442fc1e2e
commit
9a781d2e64
4 changed files with 28 additions and 9 deletions
|
@ -2,6 +2,7 @@ package web_test
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.urbach.dev/go/assert"
|
||||
|
@ -25,6 +26,25 @@ func TestRequest(t *testing.T) {
|
|||
assert.Equal(t, string(response.Body()), "GET http example.com /request")
|
||||
}
|
||||
|
||||
func TestRequestBody(t *testing.T) {
|
||||
s := web.NewServer()
|
||||
|
||||
s.Get("/", func(ctx web.Context) error {
|
||||
body := make([]byte, 4096)
|
||||
n, err := ctx.Request().Read(body)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ctx.Bytes(body[:n])
|
||||
})
|
||||
|
||||
response := s.Request("GET", "/", nil, strings.NewReader("Hello"))
|
||||
assert.Equal(t, response.Status(), 200)
|
||||
assert.Equal(t, string(response.Body()), "Hello")
|
||||
}
|
||||
|
||||
func TestRequestHeader(t *testing.T) {
|
||||
s := web.NewServer()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue