(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func 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 | } |
nothing calls this directly
no test coverage detected