From 319d61123a0418ea9caa9510b8ad1e9a302c7b93 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Thu, 17 May 2018 12:48:31 +0100 Subject: MM-10615: Reset teams/channels to default scheme on delete scheme. (#8811) --- api4/scheme_test.go | 50 ++++++++++---------------------------------------- 1 file changed, 10 insertions(+), 40 deletions(-) (limited to 'api4') diff --git a/api4/scheme_test.go b/api4/scheme_test.go index 2762ef92a..16c87cfac 100644 --- a/api4/scheme_test.go +++ b/api4/scheme_test.go @@ -615,29 +615,6 @@ func TestDeleteScheme(t *testing.T) { assert.Nil(t, res.Err) team := res.Data.(*model.Team) - // Try and fail to delete the scheme. - _, r2 := th.SystemAdminClient.DeleteScheme(s1.Id) - CheckInternalErrorStatus(t, r2) - - role1, roleRes1 = th.SystemAdminClient.GetRole(s1.DefaultTeamAdminRole) - CheckNoError(t, roleRes1) - role2, roleRes2 = th.SystemAdminClient.GetRole(s1.DefaultTeamUserRole) - CheckNoError(t, roleRes2) - role3, roleRes3 = th.SystemAdminClient.GetRole(s1.DefaultChannelAdminRole) - CheckNoError(t, roleRes3) - role4, roleRes4 = th.SystemAdminClient.GetRole(s1.DefaultChannelUserRole) - CheckNoError(t, roleRes4) - - assert.Zero(t, role1.DeleteAt) - assert.Zero(t, role2.DeleteAt) - assert.Zero(t, role3.DeleteAt) - assert.Zero(t, role4.DeleteAt) - - // Change the team using it to a different scheme. - emptyString := "" - team.SchemeId = &emptyString - res = <-th.App.Srv.Store.Team().Update(team) - // Delete the Scheme. _, r3 := th.SystemAdminClient.DeleteScheme(s1.Id) CheckNoError(t, r3) @@ -656,6 +633,11 @@ func TestDeleteScheme(t *testing.T) { assert.NotZero(t, role2.DeleteAt) assert.NotZero(t, role3.DeleteAt) assert.NotZero(t, role4.DeleteAt) + + // Check the team now uses the default scheme + c2, resp := th.SystemAdminClient.GetTeam(team.Id, "") + CheckNoError(t, resp) + assert.Equal(t, "", *c2.SchemeId) }) t.Run("ValidChannelScheme", func(t *testing.T) { @@ -702,23 +684,6 @@ func TestDeleteScheme(t *testing.T) { assert.Nil(t, res.Err) channel := res.Data.(*model.Channel) - // Try and fail to delete the scheme. - _, r2 := th.SystemAdminClient.DeleteScheme(s1.Id) - CheckInternalErrorStatus(t, r2) - - role3, roleRes3 = th.SystemAdminClient.GetRole(s1.DefaultChannelAdminRole) - CheckNoError(t, roleRes3) - role4, roleRes4 = th.SystemAdminClient.GetRole(s1.DefaultChannelUserRole) - CheckNoError(t, roleRes4) - - assert.Zero(t, role3.DeleteAt) - assert.Zero(t, role4.DeleteAt) - - // Change the team using it to a different scheme. - emptyString := "" - channel.SchemeId = &emptyString - res = <-th.App.Srv.Store.Channel().Update(channel) - // Delete the Scheme. _, r3 := th.SystemAdminClient.DeleteScheme(s1.Id) CheckNoError(t, r3) @@ -731,6 +696,11 @@ func TestDeleteScheme(t *testing.T) { assert.NotZero(t, role3.DeleteAt) assert.NotZero(t, role4.DeleteAt) + + // Check the channel now uses the default scheme + c2, resp := th.SystemAdminClient.GetChannelByName(channel.Name, channel.TeamId, "") + CheckNoError(t, resp) + assert.Equal(t, "", *c2.SchemeId) }) t.Run("FailureCases", func(t *testing.T) { -- cgit v1.2.3-1-g7c22