| 752 | } |
| 753 | |
| 754 | func TestObjectRename(t *testing.T) { |
| 755 | cases := map[string]struct { |
| 756 | old, new string |
| 757 | expected []string |
| 758 | }{ |
| 759 | "renamed": { |
| 760 | old: "foo", |
| 761 | new: "qux", |
| 762 | expected: []string{"qux", "bar"}, |
| 763 | }, |
| 764 | "unmatched": { |
| 765 | old: "baz", |
| 766 | new: "qux", |
| 767 | expected: []string{"foo", "bar"}, |
| 768 | }, |
| 769 | } |
| 770 | |
| 771 | for k, tc := range cases { |
| 772 | object := &Object{ |
| 773 | &NamedAttributeExpr{ |
| 774 | Name: "foo", |
| 775 | Attribute: &AttributeExpr{ |
| 776 | Type: String, |
| 777 | }, |
| 778 | }, |
| 779 | &NamedAttributeExpr{ |
| 780 | Name: "bar", |
| 781 | Attribute: &AttributeExpr{ |
| 782 | Type: String, |
| 783 | }, |
| 784 | }, |
| 785 | } |
| 786 | object.Rename(tc.old, tc.new) |
| 787 | for _, s := range tc.expected { |
| 788 | if att := object.Attribute(s); att == nil { |
| 789 | t.Errorf("%s: %s not found", k, s) |
| 790 | } |
| 791 | } |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | func TestObjectIsCompatible(t *testing.T) { |
| 796 | var ( |