Browse Source

More tests (#65)

more tests

Reviewed-on: #65
master
Lunny Xiao 1 month ago
parent
commit
864736cd39
1 changed files with 35 additions and 0 deletions
  1. +35
    -0
      context_test.go

+ 35
- 0
context_test.go View File

@@ -473,3 +473,38 @@ func TestContextActionTag(t *testing.T) {
expect(t, recorder.Code, http.StatusOK)
expect(t, buff.String(), "lunny")
}

type AnyAnyAction struct {
JSON
}

func (a *AnyAnyAction) Any() interface{} {
return map[string]string{
"here": "anyany",
}
}

func TestContextAnyAny(t *testing.T) {
buff := bytes.NewBufferString("")
recorder := httptest.NewRecorder()
recorder.Body = buff

o := New(
Logging(),
Recovery(false),
Return(),
Param(),
Contexts(),
)
o.Any("/", new(AnyAnyAction))

req, err := http.NewRequest("GET", "http://localhost:8000/", nil)
if err != nil {
t.Error(err)
}

o.ServeHTTP(recorder, req)

expect(t, recorder.Code, http.StatusOK)
expect(t, strings.TrimSpace(buff.String()), `{"here":"anyany"}`)
}

Loading…
Cancel
Save