MCPcopy Create free account
hub / github.com/goadesign/goa / TestObjectRename

Function TestObjectRename

expr/types_test.go:754–793  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

752}
753
754func 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
795func TestObjectIsCompatible(t *testing.T) {
796 var (

Callers

nothing calls this directly

Calls 2

RenameMethod · 0.95
AttributeMethod · 0.95

Tested by

no test coverage detected