github.com/wangkui503/aero@v1.0.0/Request_test.go (about) 1 package aero_test 2 3 import ( 4 "net/http" 5 "testing" 6 7 "github.com/aerogo/aero" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestRequest(t *testing.T) { 12 app := aero.New() 13 14 app.Get("/", func(ctx *aero.Context) string { 15 request := ctx.Request() 16 17 assert.NotEmpty(t, request.Header()) 18 assert.Empty(t, request.Host()) 19 assert.Equal(t, "HTTP/1.1", request.Protocol()) 20 assert.Equal(t, "GET", request.Method()) 21 assert.NotNil(t, request.URL()) 22 assert.Equal(t, "/", request.URL().Path) 23 24 return ctx.Text(helloWorld) 25 }) 26 27 response := getResponse(app, "/") 28 assert.Equal(t, http.StatusOK, response.Code) 29 }