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)
| 114 | // |
| 115 | // resultType("attr1", String, "attr2", Int, view1, view2) |
| 116 | func 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 | |
| 146 | func collection(elemType *ResultTypeExpr) *ResultTypeExpr { |
| 147 | return &ResultTypeExpr{ |
no test coverage detected