From c82c826960fd142b52a23250681080583fd72711 Mon Sep 17 00:00:00 2001 From: Ben Cooke Date: Mon, 7 Mar 2022 16:15:41 -0500 Subject: [PATCH] [MM-41956] Unique name error on update (#19600) * tools updates * Revert "tools updates" This reverts commit 6293297b55803c5a263e200ebd80192899666ae9. * fixing error id for duplicate name on patch endpoint * fixing broken test Co-authored-by: Benjamin Cooke Co-authored-by: Benjamin Cooke Co-authored-by: Mattermod --- store/sqlstore/group_store.go | 2 +- store/storetest/group_store.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/store/sqlstore/group_store.go b/store/sqlstore/group_store.go index ff09a600bd..11f2f22b17 100644 --- a/store/sqlstore/group_store.go +++ b/store/sqlstore/group_store.go @@ -328,7 +328,7 @@ func (s *SqlGroupStore) Update(group *model.Group) (*model.Group, error) { WHERE Id=:Id`, group) if err != nil { if IsUniqueConstraintError(err, []string{"Name", "groups_name_key"}) { - return nil, errors.Wrapf(err, "Group with name %s already exists", *group.Name) + return nil, store.NewErrUniqueConstraint("Name") } return nil, errors.Wrap(err, "failed to update Group") } diff --git a/store/storetest/group_store.go b/store/storetest/group_store.go index dba3f01376..2025ed5fd7 100644 --- a/store/storetest/group_store.go +++ b/store/storetest/group_store.go @@ -668,7 +668,7 @@ func testGroupStoreUpdate(t *testing.T, ss store.Store) { RemoteId: model.NewString(model.NewId()), }) require.Error(t, err) - require.Contains(t, err.Error(), fmt.Sprintf("Group with name %s already exists", *g1Update.Name)) + require.Contains(t, err.Error(), "unique constraint: Name") // Cannot update CreateAt someVal := model.GetMillis()