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

Function TestExampleCLIFiles

http/codegen/example_cli_test.go:18–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestExampleCLIFiles(t *testing.T) {
19 cases := []struct {
20 Name string
21 DSL func()
22 }{
23 {"no-server", ctestdata.NoServerDSL},
24 {"server-hosting-service-subset", ctestdata.ServerHostingServiceSubsetDSL},
25 {"server-hosting-multiple-services", ctestdata.ServerHostingMultipleServicesDSL},
26 {"streaming", testdata.StreamingResultDSL},
27 {"streaming-multiple-services", testdata.StreamingMultipleServicesDSL},
28 }
29 for _, c := range cases {
30 t.Run(c.Name, func(t *testing.T) {
31 // reset global variable
32 example.Servers = make(example.ServersData)
33 root := codegen.RunDSL(t, c.DSL)
34 httpServices := NewServicesData(service.NewServicesData(root), root.API.HTTP)
35 fs := ExampleCLIFiles("", httpServices)
36 require.Len(t, fs, 1)
37 require.Greater(t, len(fs[0].SectionTemplates), 0)
38 var buf bytes.Buffer
39 for _, s := range fs[0].SectionTemplates[1:] {
40 require.NoError(t, s.Write(&buf))
41 }
42 code := codegen.FormatTestCode(t, "package foo\n"+buf.String())
43 golden := filepath.Join("testdata", "golden", "client-"+c.Name+".golden")
44 testutil.CompareOrUpdateGolden(t, code, golden)
45 })
46 }
47}

Callers

nothing calls this directly

Calls 9

RunDSLFunction · 0.92
NewServicesDataFunction · 0.92
FormatTestCodeFunction · 0.92
CompareOrUpdateGoldenFunction · 0.92
NewServicesDataFunction · 0.70
ExampleCLIFilesFunction · 0.70
StringMethod · 0.65
RunMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected