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

Function TestRecursiveValidationCode

codegen/validation_test.go:12–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestRecursiveValidationCode(t *testing.T) {
13 root := RunDSL(t, testdata.ValidationTypesDSL)
14 var (
15 scope = NewNameScope()
16
17 integerT = root.UserType("Integer")
18 stringT = root.UserType("String")
19 floatT = root.UserType("Float")
20 aliasT = root.UserType("AliasType")
21 userT = root.UserType("UserType")
22 arrayUT = root.UserType("ArrayUserType")
23 arrayT = root.UserType("Array")
24 arrayReqT = root.UserType("ArrayRequired")
25 mapT = root.UserType("Map")
26 unionT = root.UserType("Union")
27 rtT = root.UserType("Result")
28 rtcolT = root.UserType("Collection")
29 colT = root.UserType("TypeWithCollection")
30 deepT = root.UserType("Deep")
31 )
32 cases := []struct {
33 Name string
34 Type expr.UserType
35 Required bool
36 Pointer bool
37 UseDefault bool
38 }{
39 {"integer-required", integerT, true, false, false},
40 {"integer-pointer", integerT, false, true, false},
41 {"integer-use-default", integerT, false, false, true},
42 {"float-required", floatT, true, false, false},
43 {"float-pointer", floatT, false, true, false},
44 {"float-use-default", floatT, false, false, true},
45 {"string-required", stringT, true, false, false},
46 {"string-pointer", stringT, false, true, false},
47 {"string-use-default", stringT, false, false, true},
48 {"alias-type", aliasT, true, false, false},
49 {"user-type-required", userT, true, false, false},
50 {"user-type-pointer", userT, false, true, false},
51 {"user-type-default", userT, false, false, true},
52 {"user-type-array-required", arrayUT, true, true, false},
53 {"array-required", arrayT, true, false, false},
54 {"array-pointer", arrayT, false, true, false},
55 {"array-use-default", arrayT, false, false, true},
56 {"array-required-non-nullable-elems", arrayReqT, true, false, false},
57 {"map-required", mapT, true, false, false},
58 {"map-pointer", mapT, false, true, false},
59 {"map-use-default", mapT, false, false, true},
60 {"union", unionT, true, false, false},
61 {"result-type-pointer", rtT, false, true, false},
62 {"collection-required", rtcolT, true, false, false},
63 {"collection-pointer", rtcolT, false, true, false},
64 {"type-with-collection-pointer", colT, false, true, false},
65 {"type-with-embedded-type", deepT, false, true, false},
66 }
67 for _, c := range cases {
68 t.Run(c.Name, func(t *testing.T) {
69 ctx := NewAttributeContext(c.Pointer, false, c.UseDefault, "", scope)

Callers

nothing calls this directly

Calls 9

IsAliasFunction · 0.92
AssertGoFunction · 0.92
NewNameScopeFunction · 0.85
NewAttributeContextFunction · 0.85
ValidationCodeFunction · 0.85
FormatTestCodeFunction · 0.85
UserTypeMethod · 0.80
RunDSLFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected