(t *testing.T)
| 486 | } |
| 487 | |
| 488 | func TestHashAttribute(t *testing.T) { |
| 489 | type ( |
| 490 | testAttr struct { |
| 491 | name string |
| 492 | att *expr.AttributeExpr |
| 493 | } |
| 494 | |
| 495 | hashBehavior int |
| 496 | |
| 497 | testGroup struct { |
| 498 | name string |
| 499 | attrs []testAttr |
| 500 | behavior hashBehavior |
| 501 | } |
| 502 | ) |
| 503 | |
| 504 | const ( |
| 505 | uniqueHashes hashBehavior = iota |
| 506 | identicalHashes |
| 507 | ) |
| 508 | |
| 509 | var ( |
| 510 | metaNotGenerate = expr.MetaExpr{"openapi:generate": []string{"false"}} |
| 511 | metaEmpty = expr.MetaExpr{} |
| 512 | ) |
| 513 | |
| 514 | cases := []testGroup{ |
| 515 | { |
| 516 | name: "Primitive types", |
| 517 | behavior: uniqueHashes, |
| 518 | attrs: []testAttr{ |
| 519 | {name: "bool", att: &expr.AttributeExpr{Type: expr.Boolean}}, |
| 520 | {name: "int", att: &expr.AttributeExpr{Type: expr.Int}}, |
| 521 | {name: "int32", att: &expr.AttributeExpr{Type: expr.Int32}}, |
| 522 | {name: "int64", att: &expr.AttributeExpr{Type: expr.Int64}}, |
| 523 | {name: "uint", att: &expr.AttributeExpr{Type: expr.UInt}}, |
| 524 | {name: "uint32", att: &expr.AttributeExpr{Type: expr.UInt32}}, |
| 525 | {name: "uint64", att: &expr.AttributeExpr{Type: expr.UInt64}}, |
| 526 | {name: "float32", att: &expr.AttributeExpr{Type: expr.Float32}}, |
| 527 | {name: "float64", att: &expr.AttributeExpr{Type: expr.Float64}}, |
| 528 | {name: "string", att: &expr.AttributeExpr{Type: expr.String}}, |
| 529 | {name: "bytes", att: &expr.AttributeExpr{Type: expr.Bytes}}, |
| 530 | {name: "any", att: &expr.AttributeExpr{Type: expr.Any}}, |
| 531 | }, |
| 532 | }, { |
| 533 | name: "Collection types", |
| 534 | behavior: uniqueHashes, |
| 535 | attrs: []testAttr{ |
| 536 | {name: "array-bool", att: &expr.AttributeExpr{Type: &expr.Array{ElemType: &expr.AttributeExpr{Type: expr.Boolean}}}}, |
| 537 | {name: "array-int", att: &expr.AttributeExpr{Type: &expr.Array{ElemType: &expr.AttributeExpr{Type: expr.Int}}}}, |
| 538 | {name: "map-str-int", att: &expr.AttributeExpr{Type: &expr.Map{KeyType: &expr.AttributeExpr{Type: expr.String}, ElemType: &expr.AttributeExpr{Type: expr.Int}}}}, |
| 539 | {name: "map-str-str", att: &expr.AttributeExpr{Type: &expr.Map{KeyType: &expr.AttributeExpr{Type: expr.String}, ElemType: &expr.AttributeExpr{Type: expr.String}}}}, |
| 540 | }, |
| 541 | }, { |
| 542 | name: "Objects with validation rules", |
| 543 | behavior: uniqueHashes, |
| 544 | attrs: []testAttr{ |
| 545 | {name: "no-validation", att: newObj("foo", false)}, |
nothing calls this directly
no test coverage detected