summaryrefslogtreecommitdiffstats
path: root/api4/scheme_test.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2018-05-17 12:48:31 +0100
committerGitHub <noreply@github.com>2018-05-17 12:48:31 +0100
commit319d61123a0418ea9caa9510b8ad1e9a302c7b93 (patch)
tree76ce7c073a2ce04e05692d7dea0a7ecd41c1a419 /api4/scheme_test.go
parentc2ab85e0a36af24ee804c1d140cfe216022a4e45 (diff)
downloadchat-319d61123a0418ea9caa9510b8ad1e9a302c7b93.tar.gz
chat-319d61123a0418ea9caa9510b8ad1e9a302c7b93.tar.bz2
chat-319d61123a0418ea9caa9510b8ad1e9a302c7b93.zip
MM-10615: Reset teams/channels to default scheme on delete scheme. (#8811)
Diffstat (limited to 'api4/scheme_test.go')
-rw-r--r--api4/scheme_test.go50
1 files changed, 10 insertions, 40 deletions
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) {