(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestServerMount(t *testing.T) { |
| 16 | const genpkg = "gen" |
| 17 | cases := []struct { |
| 18 | Name string |
| 19 | DSL func() |
| 20 | SectionNum int |
| 21 | |
| 22 | SectionName string |
| 23 | }{ |
| 24 | {"simple routing constructor", testdata.ServerSimpleRoutingDSL, 0, "server-mount"}, |
| 25 | {"simple routing with a redirect constructor", testdata.ServerSimpleRoutingWithRedirectDSL, 0, "server-mount"}, |
| 26 | {"multiple_files_constructor", testdata.ServerMultipleFilesDSL, 0, "server-mount"}, |
| 27 | {"multiple_files_mounter", testdata.ServerMultipleFilesDSL, 3, "server-files"}, |
| 28 | {"multiple_files_constructor_w_prefix_path", testdata.ServerMultipleFilesWithPrefixPathDSL, 0, "server-mount"}, |
| 29 | {"multiple_files_mounter_w_prefix_path", testdata.ServerMultipleFilesWithPrefixPathDSL, 3, "server-files"}, |
| 30 | {"multiple_files_with_a_redirect_constructor", testdata.ServerMultipleFilesWithRedirectDSL, 0, "server-mount"}, |
| 31 | {"multiple_files_with_a_redirect_mounter", testdata.ServerMultipleFilesWithRedirectDSL, 3, "server-files"}, |
| 32 | } |
| 33 | for _, c := range cases { |
| 34 | t.Run(c.Name, func(t *testing.T) { |
| 35 | root := RunHTTPDSL(t, c.DSL) |
| 36 | services := CreateHTTPServices(root) |
| 37 | fs := ServerFiles(genpkg, services) |
| 38 | sections := codegentest.Sections(fs, "server.go", c.SectionName) |
| 39 | require.Greater(t, len(sections), c.SectionNum) |
| 40 | code := codegen.SectionCode(t, sections[c.SectionNum]) |
| 41 | testutil.AssertGo(t, "testdata/golden/server_mount_"+c.Name+".go.golden", code) |
| 42 | }) |
| 43 | } |
| 44 | } |
nothing calls this directly
no test coverage detected