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

Function TestEncodeError

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

Source from the content-addressed store, hash-verified

11)
12
13func TestEncodeError(t *testing.T) {
14 cases := []struct {
15 Name string
16 DSL func()
17 }{
18 {"primitive-error-response", testdata.PrimitiveErrorResponseDSL},
19 {"primitive-error-in-response-header", testdata.PrimitiveErrorInResponseHeaderDSL},
20 {"api-primitive-error-response", testdata.APIPrimitiveErrorResponseDSL},
21 {"default-error-response", testdata.DefaultErrorResponseDSL},
22 {"default-error-response-with-content-type", testdata.DefaultErrorResponseWithContentTypeDSL},
23 {"service-error-response", testdata.ServiceErrorResponseDSL},
24 {"api-error-response", testdata.APIErrorResponseDSL},
25 {"api-error-response-with-content-type", testdata.APIErrorResponseWithContentTypeDSL},
26 {"no-body-error-response", testdata.NoBodyErrorResponseDSL},
27 {"no-body-error-response-with-content-type", testdata.NoBodyErrorResponseWithContentTypeDSL},
28 {"api-no-body-error-response", testdata.APINoBodyErrorResponseDSL},
29 {"api-no-body-error-response-with-content-type", testdata.APINoBodyErrorResponseWithContentTypeDSL},
30 {"empty-error-response-body", testdata.EmptyErrorResponseBodyDSL},
31 {"empty-custom-error-response-body", testdata.EmptyCustomErrorResponseBodyDSL},
32 }
33 for _, c := range cases {
34 t.Run(c.Name, func(t *testing.T) {
35 root := RunHTTPDSL(t, c.DSL)
36 services := CreateHTTPServices(root)
37 fs := ServerFiles("", services)
38 require.Len(t, fs, 2)
39 sections := fs[1].SectionTemplates
40 require.Greater(t, len(sections), 1)
41 code := codegen.SectionCode(t, sections[2])
42 testutil.AssertGo(t, "testdata/golden/server_error_encoder_"+c.Name+".go.golden", code)
43 })
44 }
45}

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