(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestServerInit(t *testing.T) { |
| 14 | const genpkg = "gen" |
| 15 | cases := []struct { |
| 16 | Name string |
| 17 | DSL func() |
| 18 | FileCount int |
| 19 | SectionNum int |
| 20 | }{ |
| 21 | {"multiple endpoints", testdata.ServerMultiEndpointsDSL, 2, 3}, |
| 22 | {"multiple bases", testdata.ServerMultiBasesDSL, 2, 3}, |
| 23 | {"file server", testdata.ServerFileServerDSL, 1, 3}, |
| 24 | {"file server with a redirect", testdata.ServerFileServerWithRedirectDSL, 1, 3}, |
| 25 | {"file server with root path", testdata.ServerFileServerRootPathDSL, 1, 3}, |
| 26 | {"mixed", testdata.ServerMixedDSL, 2, 3}, |
| 27 | {"multipart", testdata.ServerMultipartDSL, 2, 4}, |
| 28 | {"streaming", testdata.StreamingResultDSL, 3, 3}, |
| 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 | require.Len(t, fs, c.FileCount) |
| 36 | sections := fs[0].SectionTemplates |
| 37 | require.Greater(t, len(sections), c.SectionNum) |
| 38 | code := codegen.SectionCode(t, sections[c.SectionNum]) |
| 39 | testutil.AssertGo(t, "testdata/golden/server_init_"+c.Name+".go.golden", code) |
| 40 | }) |
| 41 | } |
| 42 | } |
nothing calls this directly
no test coverage detected