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

Function TestExampleServerFiles

grpc/codegen/example_server_test.go:16–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func 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}

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected