func TestControllerWrapping(t *testing.T) { wrapped, err := controller.Wrap(&TestController{}, "Test") if err != nil { t.Error(err) } r, _ := http.NewRequest("GET", "/", nil) response := wrapped(r) _, ok := response.(noxuhttp.TextResponse) assert.True(t, ok) }
func TestControllerWrappingTextResponseExecution(t *testing.T) { wrapped, err := controller.Wrap(&TestController{}, "Test") if err != nil { t.Error(err) } r, _ := http.NewRequest("GET", "/", nil) response := wrapped(r) textResponse, ok := response.(noxuhttp.TextResponse) assert.True(t, ok) w := httptest.NewRecorder() textResponse.Respond(w, r) bodyContents, _ := ioutil.ReadAll(w.Body) assert.Equal(t, []byte("text"), bodyContents) }