(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestHandlerInit(t *testing.T) { |
| 16 | const genpkg = "gen" |
| 17 | cases := []struct { |
| 18 | Name string |
| 19 | DSL func() |
| 20 | }{ |
| 21 | {"no payload no result", testdata.ServerNoPayloadNoResultDSL}, |
| 22 | {"no payload no result with a redirect", testdata.ServerNoPayloadNoResultWithRedirectDSL}, |
| 23 | {"payload no result", testdata.ServerPayloadNoResultDSL}, |
| 24 | {"payload no result with a redirect", testdata.ServerPayloadNoResultWithRedirectDSL}, |
| 25 | {"no payload result", testdata.ServerNoPayloadResultDSL}, |
| 26 | {"payload result", testdata.ServerPayloadResultDSL}, |
| 27 | {"payload result error", testdata.ServerPayloadResultErrorDSL}, |
| 28 | {"skip response body encode decode", testdata.ServerSkipResponseBodyEncodeDecodeDSL}, |
| 29 | } |
| 30 | for _, c := range cases { |
| 31 | t.Run(c.Name, func(t *testing.T) { |
| 32 | root := RunHTTPDSL(t, c.DSL) |
| 33 | services := CreateHTTPServices(root) |
| 34 | fs := ServerFiles(genpkg, services) |
| 35 | sections := codegentest.Sections(fs, "server.go", "server-handler-init") |
| 36 | require.Greater(t, len(sections), 0) |
| 37 | code := codegen.SectionCode(t, sections[0]) |
| 38 | testutil.AssertGo(t, "testdata/golden/handler_"+c.Name+".go.golden", code) |
| 39 | }) |
| 40 | } |
| 41 | } |
nothing calls this directly
no test coverage detected