summaryrefslogtreecommitdiffstats
path: root/app/channel_test.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2018-10-08 16:39:03 +0100
committerGitHub <noreply@github.com>2018-10-08 16:39:03 +0100
commit9a4f3ce1e5b22a297eeb00b2aaff44f88304ae8c (patch)
tree8841d645463b21a175036399e78ecae647922e55 /app/channel_test.go
parent7b338c161bce8bdede54d85a5df5a0efe34eb874 (diff)
downloadchat-9a4f3ce1e5b22a297eeb00b2aaff44f88304ae8c.tar.gz
chat-9a4f3ce1e5b22a297eeb00b2aaff44f88304ae8c.tar.bz2
chat-9a4f3ce1e5b22a297eeb00b2aaff44f88304ae8c.zip
MM-12251: Add flag to MoveChannel to remove all deactivated users. (#9515)
Diffstat (limited to 'app/channel_test.go')
-rw-r--r--app/channel_test.go31
1 files changed, 29 insertions, 2 deletions
diff --git a/app/channel_test.go b/app/channel_test.go
index 0501b9406..4b09bbb78 100644
--- a/app/channel_test.go
+++ b/app/channel_test.go
@@ -98,7 +98,7 @@ func TestMoveChannel(t *testing.T) {
t.Fatal(err)
}
- if err := th.App.MoveChannel(targetTeam, channel1, th.BasicUser); err == nil {
+ if err := th.App.MoveChannel(targetTeam, channel1, th.BasicUser, false); err == nil {
t.Fatal("Should have failed due to mismatched members.")
}
@@ -106,7 +106,34 @@ func TestMoveChannel(t *testing.T) {
t.Fatal(err)
}
- if err := th.App.MoveChannel(targetTeam, channel1, th.BasicUser); err != nil {
+ if err := th.App.MoveChannel(targetTeam, channel1, th.BasicUser, false); err != nil {
+ t.Fatal(err)
+ }
+
+ // Test moving a channel with a deactivated user who isn't in the destination team.
+ // It should fail, unless removeDeactivatedMembers is true.
+ deacivatedUser := th.CreateUser()
+ channel2 := th.CreateChannel(sourceTeam)
+
+ if _, err := th.App.AddUserToTeam(sourceTeam.Id, deacivatedUser.Id, ""); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := th.App.AddUserToChannel(th.BasicUser, channel2); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := th.App.AddUserToChannel(deacivatedUser, channel2); err != nil {
+ t.Fatal(err)
+ }
+
+ if _, err := th.App.UpdateActive(deacivatedUser, false); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := th.App.MoveChannel(targetTeam, channel2, th.BasicUser, false); err == nil {
+ t.Fatal("Should have failed due to mismatched deacivated member.")
+ }
+
+ if err := th.App.MoveChannel(targetTeam, channel2, th.BasicUser, true); err != nil {
t.Fatal(err)
}
}