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

Function runTests

http/codegen/streaming_test.go:397–433  ·  view source on GitHub ↗
(t *testing.T, cases []*testCase, filesFn func(root *expr.RootExpr) []*codegen.File)

Source from the content-addressed store, hash-verified

395}
396
397func runTests(t *testing.T, cases []*testCase, filesFn func(root *expr.RootExpr) []*codegen.File) {
398 for _, c := range cases {
399 t.Run(c.Name, func(t *testing.T) {
400 root := RunHTTPDSL(t, c.DSL)
401 fs := filesFn(root)
402 require.Greater(t, len(fs), 1)
403 for _, s := range c.Sections {
404 var code string
405 var f *codegen.File
406 if s.Name == "server-handler-init" || s.Name == "client-endpoint-init" {
407 // server.go || client.go
408 f = fs[0]
409 } else {
410 // websocket.go
411 f = fs[1]
412 }
413 sections := f.Section(s.Name)
414 seclen := len(sections)
415 if seclen > 0 {
416 code = codegen.SectionCode(t, sections[0])
417 }
418 switch {
419 case seclen == 0 && s.Code == nil:
420 // Test passed: no section found and no expected section code
421 case seclen == 0 && s.Code != nil:
422 // Test failed: no section found, but expected section code
423 t.Errorf("invalid code for %s: got 0 %s sections, expected at least one", f.Path, s.Name)
424 case seclen > 0 && s.Code == nil:
425 // Test failed: section exists in file, but no code expected.
426 t.Errorf("invalid code for %s: got %d %s sections, expected 0.\n%s", f.Path, seclen, s.Name, code)
427 default:
428 assert.Equal(t, *s.Code, code)
429 }
430 }
431 })
432 }
433}

Callers 2

TestServerStreamingFunction · 0.85
TestClientStreamingFunction · 0.85

Calls 4

SectionMethod · 0.95
SectionCodeFunction · 0.92
RunHTTPDSLFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected