(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestPaths(t *testing.T) { |
| 14 | cases := []struct { |
| 15 | Name string |
| 16 | DSL func() |
| 17 | }{ |
| 18 | {"single-path-no-param", testdata.PathNoParamDSL}, |
| 19 | {"single-path-one-param", testdata.PathOneParamDSL}, |
| 20 | {"single-path-multiple-params", testdata.PathMultipleParamsDSL}, |
| 21 | {"alternative-paths", testdata.PathAlternativesDSL}, |
| 22 | {"path-with-string-slice-param", testdata.PathStringSliceParamDSL}, |
| 23 | {"path-with-int-slice-param", testdata.PathIntSliceParamDSL}, |
| 24 | {"path-with-int32-slice-param", testdata.PathInt32SliceParamDSL}, |
| 25 | {"path-with-int64-slice-param", testdata.PathInt64SliceParamDSL}, |
| 26 | {"path-with-uint-slice-param", testdata.PathUintSliceParamDSL}, |
| 27 | {"path-with-uint32-slice-param", testdata.PathUint32SliceParamDSL}, |
| 28 | {"path-with-uint64-slice-param", testdata.PathUint64SliceParamDSL}, |
| 29 | {"path-with-float33-slice-param", testdata.PathFloat32SliceParamDSL}, |
| 30 | {"path-with-float64-slice-param", testdata.PathFloat64SliceParamDSL}, |
| 31 | {"path-with-bool-slice-param", testdata.PathBoolSliceParamDSL}, |
| 32 | {"path-with-interface-slice-param", testdata.PathInterfaceSliceParamDSL}, |
| 33 | } |
| 34 | |
| 35 | for _, c := range cases { |
| 36 | t.Run(c.Name, func(t *testing.T) { |
| 37 | root := RunHTTPDSL(t, c.DSL) |
| 38 | require.Len(t, root.API.HTTP.Services, 1) |
| 39 | services := CreateHTTPServices(root) |
| 40 | fs := serverPath(root.API.HTTP.Services[0], services) |
| 41 | sections := fs.SectionTemplates |
| 42 | code := codegen.SectionCode(t, sections[1]) |
| 43 | testutil.AssertGo(t, "testdata/golden/paths_"+c.Name+".go.golden", code) |
| 44 | }) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func TestPathTrailingShash(t *testing.T) { |
| 49 | cases := []struct { |
nothing calls this directly
no test coverage detected