(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestBuildPathFromFileServer(t *testing.T) { |
| 15 | cases := []struct { |
| 16 | path string |
| 17 | expected string |
| 18 | }{ |
| 19 | { |
| 20 | path: "/foo", |
| 21 | expected: "/foo", |
| 22 | }, |
| 23 | { |
| 24 | path: "/foo/{bar}", |
| 25 | expected: "/foo/{bar}", |
| 26 | }, |
| 27 | { |
| 28 | path: "/foo/{*bar}", |
| 29 | expected: "/foo/{bar}", |
| 30 | }, |
| 31 | } |
| 32 | for _, tc := range cases { |
| 33 | t.Run(tc.path, func(t *testing.T) { |
| 34 | s := &V2{ |
| 35 | Paths: make(map[string]any), |
| 36 | } |
| 37 | root := &expr.RootExpr{ |
| 38 | API: &expr.APIExpr{ |
| 39 | ExampleGenerator: expr.NewRandom("test"), |
| 40 | }, |
| 41 | } |
| 42 | fs := &expr.HTTPFileServerExpr{ |
| 43 | Service: &expr.HTTPServiceExpr{ |
| 44 | ServiceExpr: &expr.ServiceExpr{ |
| 45 | Name: "service", |
| 46 | }, |
| 47 | }, |
| 48 | RequestPaths: []string{tc.path}, |
| 49 | } |
| 50 | buildPathFromFileServer(s, root, fs) |
| 51 | for actual := range s.Paths { |
| 52 | if actual != tc.expected { |
| 53 | t.Errorf("got %#v, expected %#v", actual, tc.expected) |
| 54 | } |
| 55 | } |
| 56 | }) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | func TestNoSecurityOverridesAPISecurity(t *testing.T) { |
| 61 | root := codegen.RunDSL(t, noSecurityOverridesAPISecurityDSL) |
nothing calls this directly
no test coverage detected