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

Function TestExampleCLIFiles

grpc/codegen/example_cli_test.go:17–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected