(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestExampleCLIFiles(t *testing.T) { |
| 15 | cases := []struct { |
| 16 | Name string |
| 17 | DSL func() |
| 18 | }{ |
| 19 | {"no-server", testdata.NoServerDSL}, |
| 20 | {"single-server-single-host", testdata.SingleServerSingleHostDSL}, |
| 21 | {"single-server-single-host-with-variables", testdata.SingleServerSingleHostWithVariablesDSL}, |
| 22 | {"single-server-multiple-hosts", testdata.SingleServerMultipleHostsDSL}, |
| 23 | {"single-server-multiple-hosts-with-variables", testdata.SingleServerMultipleHostsWithVariablesDSL}, |
| 24 | } |
| 25 | for _, c := range cases { |
| 26 | t.Run(c.Name, func(t *testing.T) { |
| 27 | // reset global variable |
| 28 | Servers = make(ServersData) |
| 29 | root := codegen.RunDSL(t, c.DSL) |
| 30 | fs := CLIFiles("", root) |
| 31 | require.Len(t, fs, 1) |
| 32 | require.Greater(t, len(fs[0].SectionTemplates), 0) |
| 33 | var buf bytes.Buffer |
| 34 | for _, s := range fs[0].SectionTemplates[1:] { |
| 35 | require.NoError(t, s.Write(&buf)) |
| 36 | } |
| 37 | code := codegen.FormatTestCode(t, "package foo\n"+buf.String()) |
| 38 | golden := filepath.Join("testdata", "client-"+c.Name+".golden") |
| 39 | compareOrUpdateGolden(t, code, golden) |
| 40 | }) |
| 41 | } |
| 42 | } |
nothing calls this directly
no test coverage detected