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

Function TestServerInit

http/codegen/server_init_test.go:13–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestServerInit(t *testing.T) {
14 const genpkg = "gen"
15 cases := []struct {
16 Name string
17 DSL func()
18 FileCount int
19 SectionNum int
20 }{
21 {"multiple endpoints", testdata.ServerMultiEndpointsDSL, 2, 3},
22 {"multiple bases", testdata.ServerMultiBasesDSL, 2, 3},
23 {"file server", testdata.ServerFileServerDSL, 1, 3},
24 {"file server with a redirect", testdata.ServerFileServerWithRedirectDSL, 1, 3},
25 {"file server with root path", testdata.ServerFileServerRootPathDSL, 1, 3},
26 {"mixed", testdata.ServerMixedDSL, 2, 3},
27 {"multipart", testdata.ServerMultipartDSL, 2, 4},
28 {"streaming", testdata.StreamingResultDSL, 3, 3},
29 }
30 for _, c := range cases {
31 t.Run(c.Name, func(t *testing.T) {
32 root := RunHTTPDSL(t, c.DSL)
33 services := CreateHTTPServices(root)
34 fs := ServerFiles(genpkg, services)
35 require.Len(t, fs, c.FileCount)
36 sections := fs[0].SectionTemplates
37 require.Greater(t, len(sections), c.SectionNum)
38 code := codegen.SectionCode(t, sections[c.SectionNum])
39 testutil.AssertGo(t, "testdata/golden/server_init_"+c.Name+".go.golden", code)
40 })
41 }
42}

Callers

nothing calls this directly

Calls 6

SectionCodeFunction · 0.92
AssertGoFunction · 0.92
RunHTTPDSLFunction · 0.85
CreateHTTPServicesFunction · 0.85
ServerFilesFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected