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

Function TestFiles

http/codegen/openapi/v3/files_test.go:21–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestFiles(t *testing.T) {
22 var (
23 goldenPath = filepath.Join("testdata", "golden")
24 )
25 cases := []struct {
26 Name string
27 DSL func()
28 }{
29 // TestSections
30 {"file-service", testdata.FileServiceDSL},
31 {"file-service-swagger", testdata.FileServiceSwaggerDSL},
32 {"file-service-wildcard", testdata.FileServiceWildcardDSL},
33 {"valid", testdata.SimpleDSL},
34 {"multiple-services", testdata.MultipleServicesDSL},
35 {"multiple-views", testdata.MultipleViewsDSL},
36 {"explicit-view", testdata.ExplicitViewDSL},
37 {"security", testdata.SecurityDSL},
38 {"bearer-security", testdata.BearerSecurityDSL},
39 {"server-host-with-variables", testdata.ServerHostWithVariablesDSL},
40 {"with-spaces", testdata.WithSpacesDSL},
41 {"with-map", testdata.WithMapDSL},
42 {"with-any", testdata.WithAnyDSL},
43 {"path-with-wildcards", testdata.PathWithWildcardDSL},
44 {"path-with-multiple-wildcards", testdata.PathWithMultipleWildcardDSL},
45 {"path-with-multiple-explicit-wildcards", testdata.PathWithMultipleExplicitWildcardDSL},
46 {"headers", testdata.HeadersDSL},
47 {"with-tags", testdata.WithTagsDSL},
48 {"with-tags-swagger", testdata.WithTagsSwaggerDSL},
49 {"typename", testdata.TypenameDSL},
50 {"not-generate-server", testdata.NotGenerateServerDSL},
51 {"not-generate-host", testdata.NotGenerateHostDSL},
52 {"not-generate-attribute", testdata.NotGenerateAttributeDSL},
53 {"json-prefix", testdata.JSONPrefixDSL},
54 {"json-indent", testdata.JSONIndentDSL},
55 {"json-prefix-indent", testdata.JSONPrefixIndentDSL},
56 // TestEndpoints
57 {"endpoint", testdata.ExtensionDSL},
58 {"endpoint-swagger", testdata.ExtensionSwaggerDSL},
59 {"skip-response-body-encode-decode", testdata.SkipResponseBodyEncodeDecodeDSL},
60 // TestValidations
61 {"string", testdata.StringValidationDSL},
62 {"integer", testdata.IntValidationDSL},
63 {"array", testdata.ArrayValidationDSL},
64 // Error examples
65 {"error-examples", testdata.ErrorExamplesDSL},
66 }
67 for _, c := range cases {
68 t.Run(c.Name, func(t *testing.T) {
69 // Reset global variables
70 openapi.Definitions = make(map[string]*openapi.Schema)
71 root := httpgen.RunHTTPDSL(t, c.DSL)
72 oFiles, err := openapiv3.Files(root)
73 if err != nil {
74 t.Fatalf("OpenAPI failed with %s", err)
75 }
76 for i, o := range oFiles {
77 tname := fmt.Sprintf("file%d", i)
78 s := o.SectionTemplates

Callers

nothing calls this directly

Calls 6

AssertJSONFunction · 0.92
AssertStringFunction · 0.92
ExecuteMethod · 0.80
validateSwaggerFunction · 0.70
StringMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected