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

Function TestBuildPathFromFileServer

http/codegen/openapi/v2/builder_test.go:14–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func 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
60func TestNoSecurityOverridesAPISecurity(t *testing.T) {
61 root := codegen.RunDSL(t, noSecurityOverridesAPISecurityDSL)

Callers

nothing calls this directly

Calls 3

NewRandomFunction · 0.92
buildPathFromFileServerFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected