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

Function TestErrorExprValidate

expr/service_test.go:109–135  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

107}
108
109func TestErrorExprValidate(t *testing.T) {
110 cases := []struct {
111 Name string
112 DSL func()
113 Error string
114 }{
115 {"no error", testdata.ValidErrorsDSL, ""},
116 {"invalid-struct-error-name-meta", testdata.InvalidStructErrorNameDSL,
117 `attribute: error name "a" must be required in type "ServiceError"
118attribute: duplicate error names in type "Error"
119attribute: error name "a" must be a string in type "Error"
120attribute: error name "a" must be required in type "Error"
121attribute: type "ErrorType" is used to define multiple errors and must identify the attribute containing the error name with ErrorName
122attribute: type "ErrorType" is used to define multiple errors and must identify the attribute containing the error name with ErrorName`,
123 },
124 }
125 for _, tc := range cases {
126 t.Run(tc.Name, func(t *testing.T) {
127 if tc.Error == "" {
128 expr.RunDSL(t, tc.DSL)
129 } else {
130 err := expr.RunInvalidDSL(t, tc.DSL)
131 assert.EqualError(t, err, tc.Error)
132 }
133 })
134 }
135}

Callers

nothing calls this directly

Calls 3

RunDSLFunction · 0.92
RunInvalidDSLFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected