MCPcopy Create free account
hub / github.com/goadesign/goa / TestExampleCLIFiles

Function TestExampleCLIFiles

codegen/example/example_client_test.go:14–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func 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}

Callers

nothing calls this directly

Calls 7

RunDSLFunction · 0.92
FormatTestCodeFunction · 0.92
CLIFilesFunction · 0.85
compareOrUpdateGoldenFunction · 0.70
StringMethod · 0.65
RunMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected