Added Reader and String
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.akyoto.dev/go/assert"
|
||||
@ -26,6 +27,14 @@ func TestRouter(t *testing.T) {
|
||||
return ctx.Error(http.StatusUnauthorized, errors.New("Not logged in"))
|
||||
})
|
||||
|
||||
s.Get("/reader", func(ctx server.Context) error {
|
||||
return ctx.Reader(strings.NewReader("Hello"))
|
||||
})
|
||||
|
||||
s.Get("/string", func(ctx server.Context) error {
|
||||
return ctx.String("Hello")
|
||||
})
|
||||
|
||||
tests := []struct {
|
||||
URL string
|
||||
Status int
|
||||
@ -35,6 +44,8 @@ func TestRouter(t *testing.T) {
|
||||
{URL: "/blog/post", Status: http.StatusOK, Body: "Hello"},
|
||||
{URL: "/error", Status: http.StatusUnauthorized, Body: "Not logged in"},
|
||||
{URL: "/not-found", Status: http.StatusNotFound, Body: http.StatusText(http.StatusNotFound)},
|
||||
{URL: "/reader", Status: http.StatusOK, Body: "Hello"},
|
||||
{URL: "/string", Status: http.StatusOK, Body: "Hello"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Reference in New Issue
Block a user