(t *testing.T)
| 31 | } |
| 32 | |
| 33 | func TestStruct(t *testing.T) { |
| 34 | app := iris.New() |
| 35 | |
| 36 | b := New() |
| 37 | s := b.Struct(&testStruct{}, 0) |
| 38 | |
| 39 | postHandler := s.MethodHandler("MyHandler", 0) // fallbacks such as {path} and {string} should registered first when same path. |
| 40 | app.Post("/{name:string}", postHandler) |
| 41 | postHandler2 := s.MethodHandler("MyHandler2", 0) |
| 42 | app.Post("/{id:int}", postHandler2) |
| 43 | postHandler3 := s.MethodHandler("MyHandler3", 0) |
| 44 | app.Post("/myHandler3", postHandler3) |
| 45 | getHandler := s.MethodHandler("MyHandler4", 0) |
| 46 | app.Get("/myHandler4", getHandler) |
| 47 | |
| 48 | e := httptest.New(t, app) |
| 49 | e.POST("/" + input.Name).Expect().Status(httptest.StatusOK).JSON().IsEqual(expectedOutput) |
| 50 | path := fmt.Sprintf("/%d", expectedOutput.ID) |
| 51 | e.POST(path).WithJSON(input).Expect().Status(httptest.StatusOK).JSON().IsEqual(expectedOutput) |
| 52 | e.POST("/myHandler3").WithJSON(input).Expect().Status(httptest.StatusOK).JSON().IsEqual(expectedOutput) |
| 53 | e.GET("/myHandler4").Expect().Status(httptest.StatusOK).Body().IsEqual("MyHandler4") |
| 54 | } |
| 55 | |
| 56 | type testStructErrorHandler struct{} |
| 57 |
nothing calls this directly
no test coverage detected
searching dependent graphs…