(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestGoTypeDef(t *testing.T) { |
| 13 | // types to test |
| 14 | var ( |
| 15 | mixed = &expr.AttributeExpr{ |
| 16 | Type: &expr.Object{ |
| 17 | &expr.NamedAttributeExpr{ |
| 18 | Name: "required", |
| 19 | Attribute: &expr.AttributeExpr{Type: expr.String}, |
| 20 | }, |
| 21 | &expr.NamedAttributeExpr{ |
| 22 | Name: "default", |
| 23 | Attribute: &expr.AttributeExpr{Type: expr.Int, DefaultValue: 0}, |
| 24 | }, |
| 25 | &expr.NamedAttributeExpr{ |
| 26 | Name: "optional", |
| 27 | Attribute: &expr.AttributeExpr{Type: expr.Float32}, |
| 28 | }, |
| 29 | &expr.NamedAttributeExpr{ |
| 30 | Name: "bytes", |
| 31 | Attribute: &expr.AttributeExpr{Type: expr.Bytes}, |
| 32 | }, |
| 33 | &expr.NamedAttributeExpr{ |
| 34 | Name: "any", |
| 35 | Attribute: &expr.AttributeExpr{Type: expr.Any}, |
| 36 | }, |
| 37 | &expr.NamedAttributeExpr{ |
| 38 | Name: "required_bytes", |
| 39 | Attribute: &expr.AttributeExpr{Type: expr.Bytes}, |
| 40 | }, |
| 41 | &expr.NamedAttributeExpr{ |
| 42 | Name: "required_any", |
| 43 | Attribute: &expr.AttributeExpr{Type: expr.Any}, |
| 44 | }, |
| 45 | &expr.NamedAttributeExpr{ |
| 46 | Name: "default_bytes", |
| 47 | Attribute: &expr.AttributeExpr{Type: expr.Bytes, DefaultValue: []byte("foo")}, |
| 48 | }, |
| 49 | &expr.NamedAttributeExpr{ |
| 50 | Name: "default_any", |
| 51 | Attribute: &expr.AttributeExpr{Type: expr.Any, DefaultValue: "foo"}, |
| 52 | }, |
| 53 | &expr.NamedAttributeExpr{ |
| 54 | Name: "custom_type", |
| 55 | Attribute: &expr.AttributeExpr{Type: expr.String, Meta: expr.MetaExpr{"struct:field:type": []string{"pkg.String"}}}, |
| 56 | }, |
| 57 | &expr.NamedAttributeExpr{ |
| 58 | Name: "custom_tag", |
| 59 | Attribute: &expr.AttributeExpr{Type: expr.String, Meta: expr.MetaExpr{"struct:tag:foo": []string{"bar"}}}, |
| 60 | }, |
| 61 | }, |
| 62 | Validation: &expr.ValidationExpr{ |
| 63 | Required: []string{"required", "required_bytes", "required_any"}, |
| 64 | }, |
| 65 | } |
| 66 | ) |
| 67 | |
| 68 | cases := []struct { |
| 69 | Name string |
nothing calls this directly
no test coverage detected