(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestGoTypeDef(t *testing.T) { |
| 10 | var ( |
| 11 | simpleArray = &expr.AttributeExpr{ |
| 12 | Type: &expr.Array{ElemType: &expr.AttributeExpr{Type: expr.Boolean}}} |
| 13 | simpleMap = &expr.AttributeExpr{ |
| 14 | Type: &expr.Map{ |
| 15 | KeyType: &expr.AttributeExpr{Type: expr.Int}, |
| 16 | ElemType: &expr.AttributeExpr{Type: expr.String}, |
| 17 | }} |
| 18 | requiredObj = &expr.AttributeExpr{ |
| 19 | Type: &expr.Object{ |
| 20 | {Name: "IntField", Attribute: &expr.AttributeExpr{Type: expr.Int}}, |
| 21 | {Name: "StringField", Attribute: &expr.AttributeExpr{Type: expr.String}}, |
| 22 | }, |
| 23 | Validation: &expr.ValidationExpr{Required: []string{"IntField", "StringField"}}} |
| 24 | defaultObj = &expr.AttributeExpr{ |
| 25 | Type: &expr.Object{ |
| 26 | {Name: "IntField", Attribute: &expr.AttributeExpr{Type: expr.Int, DefaultValue: 1}}, |
| 27 | {Name: "StringField", Attribute: &expr.AttributeExpr{Type: expr.String, DefaultValue: "foo"}}, |
| 28 | }} |
| 29 | ut = &expr.UserTypeExpr{AttributeExpr: &expr.AttributeExpr{Type: expr.Boolean}, TypeName: "UserType"} |
| 30 | rt = &expr.ResultTypeExpr{UserTypeExpr: &expr.UserTypeExpr{AttributeExpr: &expr.AttributeExpr{Type: expr.Boolean}, TypeName: "ResultType"}, Identifier: "application/vnd.goa.example", Views: nil} |
| 31 | userType = &expr.AttributeExpr{Type: ut} |
| 32 | resultType = &expr.AttributeExpr{Type: rt} |
| 33 | stringMetaType = expr.MetaExpr{"struct:field:type": []string{"string"}} |
| 34 | jsonWithImportMetaType = expr.MetaExpr{"struct:field:type": []string{"json.RawMessage", "encoding/json"}} |
| 35 | jsonWithRenameMetaType = expr.MetaExpr{"struct:field:type": []string{"jason.RawMessage", "encoding/json", "jason"}} |
| 36 | structPkgPathMetaType = expr.MetaExpr{"struct:pkg:path": []string{"types"}} |
| 37 | nestedStructPkgPathMetaType = expr.MetaExpr{"struct:pkg:path": []string{"nested/pkg"}} |
| 38 | utPkgPathMeta = &expr.UserTypeExpr{AttributeExpr: &expr.AttributeExpr{Type: expr.Boolean, Meta: structPkgPathMetaType}, TypeName: "UserType"} |
| 39 | nestedUTPkgPathMeta = &expr.UserTypeExpr{AttributeExpr: &expr.AttributeExpr{Type: expr.Boolean, Meta: nestedStructPkgPathMetaType}, TypeName: "NestedUserType"} |
| 40 | |
| 41 | mixedObj = &expr.AttributeExpr{ |
| 42 | Type: &expr.Object{ |
| 43 | {Name: "IntField", Attribute: &expr.AttributeExpr{Type: expr.Int}}, |
| 44 | {Name: "ArrayField", Attribute: simpleArray}, |
| 45 | {Name: "MapField", Attribute: simpleMap}, |
| 46 | {Name: "UserTypeField", Attribute: userType}, |
| 47 | {Name: "MetaTypeField", Attribute: &expr.AttributeExpr{Type: expr.Int, Meta: jsonWithImportMetaType}}, |
| 48 | {Name: "QualifiedMetaTypeField", Attribute: &expr.AttributeExpr{Type: expr.Int, Meta: jsonWithRenameMetaType}}, |
| 49 | {Name: "StructPkgPath", Attribute: &expr.AttributeExpr{Type: utPkgPathMeta}}, |
| 50 | {Name: "NestedStructPkgPath", Attribute: &expr.AttributeExpr{Type: nestedUTPkgPathMeta}}, |
| 51 | }, |
| 52 | Validation: &expr.ValidationExpr{Required: []string{"IntField", "ArrayField", "MapField", "UserTypeField", "MetaTypeField", "QualifiedMetaTypeField"}}} |
| 53 | mixedObjWithStructPkgPath = &expr.AttributeExpr{ |
| 54 | Type: &expr.Object{ |
| 55 | {Name: "IntField", Attribute: &expr.AttributeExpr{Type: expr.Int}}, |
| 56 | {Name: "ArrayField", Attribute: simpleArray}, |
| 57 | {Name: "MapField", Attribute: simpleMap}, |
| 58 | {Name: "UserTypeField", Attribute: userType}, |
| 59 | {Name: "MetaTypeField", Attribute: &expr.AttributeExpr{Type: expr.Int, Meta: jsonWithImportMetaType}}, |
| 60 | {Name: "QualifiedMetaTypeField", Attribute: &expr.AttributeExpr{Type: expr.Int, Meta: jsonWithRenameMetaType}}, |
| 61 | {Name: "StructPkgPath", Attribute: &expr.AttributeExpr{Type: utPkgPathMeta}}, |
| 62 | {Name: "NestedStructPkgPath", Attribute: &expr.AttributeExpr{Type: nestedUTPkgPathMeta}}, |
| 63 | }, |
| 64 | Validation: &expr.ValidationExpr{Required: []string{"IntField", "ArrayField", "MapField", "UserTypeField", "MetaTypeField", "QualifiedMetaTypeField"}}, |
| 65 | Meta: structPkgPathMetaType, |
| 66 | } |
nothing calls this directly
no test coverage detected