(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestClientCLIFiles(t *testing.T) { |
| 12 | cases := []struct { |
| 13 | Name string |
| 14 | DSL func() |
| 15 | FileIndex int |
| 16 | SectionIndex int |
| 17 | }{ |
| 18 | {"no-payload-parse", testdata.MultiNoPayloadDSL, 0, 3}, |
| 19 | {"simple-parse", testdata.MultiSimpleDSL, 0, 3}, |
| 20 | {"multi-parse", testdata.MultiDSL, 0, 3}, |
| 21 | {"multi-required-payload", testdata.MultiRequiredPayloadDSL, 0, 3}, |
| 22 | {"skip-request-body-encode-decode", testdata.SkipRequestBodyEncodeDecodeDSL, 0, 3}, |
| 23 | {"streaming-parse", testdata.StreamingMultipleServicesDSL, 0, 3}, |
| 24 | {"simple-build", testdata.MultiSimpleDSL, 1, 1}, |
| 25 | {"multi-build", testdata.MultiDSL, 1, 1}, |
| 26 | {"bool-build", testdata.PayloadQueryBoolDSL, 1, 1}, |
| 27 | {"uint32-build", testdata.PayloadQueryUInt32DSL, 1, 1}, |
| 28 | {"uint64-build", testdata.PayloadQueryUIntDSL, 1, 1}, |
| 29 | {"string-build", testdata.PayloadQueryStringDSL, 1, 1}, |
| 30 | {"string-required-build", testdata.PayloadQueryStringValidateDSL, 1, 1}, |
| 31 | {"string-default-build", testdata.PayloadQueryStringDefaultDSL, 1, 1}, |
| 32 | {"body-query-path-object-build", testdata.PayloadBodyQueryPathObjectDSL, 1, 1}, |
| 33 | {"param-validation-build", testdata.ParamValidateDSL, 1, 1}, |
| 34 | {"payload-primitive-type", testdata.PayloadBodyPrimitiveBoolValidateDSL, 0, 3}, |
| 35 | {"payload-array-primitive-type", testdata.PayloadBodyPrimitiveArrayStringValidateDSL, 0, 3}, |
| 36 | {"payload-array-user-type", testdata.PayloadBodyInlineArrayUserDSL, 1, 1}, |
| 37 | {"payload-map-user-type", testdata.PayloadBodyInlineMapUserDSL, 1, 1}, |
| 38 | {"payload-object-type", testdata.PayloadBodyInlineObjectDSL, 1, 1}, |
| 39 | {"payload-object-default-type", testdata.PayloadBodyInlineObjectDefaultDSL, 1, 1}, |
| 40 | {"map-query", testdata.PayloadMapQueryPrimitiveArrayDSL, 0, 3}, |
| 41 | {"map-query-object", testdata.PayloadMapQueryObjectDSL, 1, 1}, |
| 42 | {"empty-body-build", testdata.PayloadBodyPrimitiveFieldEmptyDSL, 1, 1}, |
| 43 | {"with-params-and-headers-dsl", testdata.WithParamsAndHeadersBlockDSL, 1, 1}, |
| 44 | {"body-custom-name", testdata.PayloadBodyCustomNameDSL, 1, 1}, |
| 45 | {"path-custom-name", testdata.PayloadPathCustomNameDSL, 1, 1}, |
| 46 | {"query-custom-name", testdata.PayloadQueryCustomNameDSL, 1, 1}, |
| 47 | {"header-custom-name", testdata.PayloadHeaderCustomNameDSL, 1, 1}, |
| 48 | {"cookie-custom-name", testdata.PayloadCookieCustomNameDSL, 1, 1}, |
| 49 | } |
| 50 | |
| 51 | for _, c := range cases { |
| 52 | t.Run(c.Name, func(t *testing.T) { |
| 53 | root := RunHTTPDSL(t, c.DSL) |
| 54 | services := CreateHTTPServices(root) |
| 55 | fs := ClientCLIFiles("", services) |
| 56 | sections := fs[c.FileIndex].SectionTemplates |
| 57 | code := codegen.SectionCode(t, sections[c.SectionIndex]) |
| 58 | testutil.AssertGo(t, "testdata/golden/client_cli_"+c.Name+".go.golden", code) |
| 59 | }) |
| 60 | } |
| 61 | } |
nothing calls this directly
no test coverage detected