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

Function resultType

expr/project_test.go:116–144  ·  view source on GitHub ↗

resultType is a helper function that builds result type expressions used in tests. The arguments is a list of attribute name and type pairs followed by a list of view expressions, e.g.: resultType("attr1", String, "attr2", Int, view1, view2)

(params ...any)

Source from the content-addressed store, hash-verified

114//
115// resultType("attr1", String, "attr2", Int, view1, view2)
116func resultType(params ...any) *ResultTypeExpr {
117 var (
118 views []*ViewExpr
119 obj Object
120 )
121 for i, p := range params {
122 switch pt := p.(type) {
123 case string:
124 obj = append(obj, &NamedAttributeExpr{
125 Name: params[i].(string),
126 Attribute: &AttributeExpr{
127 Type: params[i+1].(DataType),
128 Description: fmt.Sprintf("desc %s", params[i]),
129 }})
130 case *ViewExpr:
131 views = append(views, pt)
132 }
133 }
134
135 t := testrand.String()
136 return &ResultTypeExpr{
137 UserTypeExpr: &UserTypeExpr{
138 AttributeExpr: &AttributeExpr{Type: &obj},
139 TypeName: t,
140 },
141 Identifier: "vnd.application." + t,
142 Views: views,
143 }
144}
145
146func collection(elemType *ResultTypeExpr) *ResultTypeExpr {
147 return &ResultTypeExpr{

Callers 2

project_test.goFile · 0.85
resultRecursiveFunction · 0.85

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected