(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestExampleServerFiles(t *testing.T) { |
| 17 | cases := []struct { |
| 18 | Name string |
| 19 | DSL func() |
| 20 | }{ |
| 21 | {"no-server", ctestdata.NoServerDSL}, |
| 22 | {"server-hosting-service-subset", ctestdata.ServerHostingServiceSubsetDSL}, |
| 23 | {"server-hosting-multiple-services", ctestdata.ServerHostingMultipleServicesDSL}, |
| 24 | } |
| 25 | for _, c := range cases { |
| 26 | t.Run(c.Name, func(t *testing.T) { |
| 27 | // reset global variable |
| 28 | example.Servers = make(example.ServersData) |
| 29 | root := codegen.RunDSL(t, c.DSL) |
| 30 | services := NewServicesData(service.NewServicesData(root)) |
| 31 | fs := ExampleServerFiles("", services) |
| 32 | require.Greater(t, len(fs), 0) |
| 33 | require.Greater(t, len(fs[0].SectionTemplates), 0) |
| 34 | var buf bytes.Buffer |
| 35 | for _, s := range fs[0].SectionTemplates[1:] { |
| 36 | require.NoError(t, s.Write(&buf)) |
| 37 | } |
| 38 | code := codegen.FormatTestCode(t, "package foo\n"+buf.String()) |
| 39 | golden := filepath.Join("testdata", "server-"+c.Name+".golden") |
| 40 | testutil.AssertGo(t, golden, code) |
| 41 | }) |
| 42 | } |
| 43 | } |
nothing calls this directly
no test coverage detected