summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-08-09 21:36:27 +0100
committerChristopher Speller <crspeller@gmail.com>2017-08-09 13:36:27 -0700
commitab13de96a053123e6f73ffddb763e0fe96e0f6ed (patch)
tree05e2017a6eced25d09244585ee533e0fe88ef7d8 /app
parentff0811e4a4f5189293b54a1d195eaec30b3e530f (diff)
downloadchat-ab13de96a053123e6f73ffddb763e0fe96e0f6ed.tar.gz
chat-ab13de96a053123e6f73ffddb763e0fe96e0f6ed.tar.bz2
chat-ab13de96a053123e6f73ffddb763e0fe96e0f6ed.zip
PLT-7288: Allow CLI to delete teams with no channels. (#7135)
Diffstat (limited to 'app')
-rw-r--r--app/team.go4
-rw-r--r--app/team_test.go20
2 files changed, 23 insertions, 1 deletions
diff --git a/app/team.go b/app/team.go
index e4a71d7d5..b479ed134 100644
--- a/app/team.go
+++ b/app/team.go
@@ -735,7 +735,9 @@ func PermanentDeleteTeam(team *model.Team) *model.AppError {
}
if result := <-Srv.Store.Channel().GetTeamChannels(team.Id); result.Err != nil {
- return result.Err
+ if result.Err.Id != "store.sql_channel.get_channels.not_found.app_error" {
+ return result.Err
+ }
} else {
channels := result.Data.(*model.ChannelList)
for _, c := range *channels {
diff --git a/app/team_test.go b/app/team_test.go
index a410d6652..4e0ea82f5 100644
--- a/app/team_test.go
+++ b/app/team_test.go
@@ -152,4 +152,24 @@ func TestPermanentDeleteTeam(t *testing.T) {
if command, err = GetCommand(command.Id); command != nil || err == nil {
t.Fatal("command wasn't deleted")
}
+
+ // Test deleting a team with no channels.
+ team = th.CreateTeam()
+ defer func() {
+ PermanentDeleteTeam(team)
+ }()
+
+ if channels, err := GetPublicChannelsForTeam(team.Id, 0, 1000); err != nil {
+ t.Fatal(err)
+ } else {
+ for _, channel := range *channels {
+ if err2 := PermanentDeleteChannel(channel); err2 != nil {
+ t.Fatal(err)
+ }
+ }
+ }
+
+ if err := PermanentDeleteTeam(team); err != nil {
+ t.Fatal(err)
+ }
}