summaryrefslogtreecommitdiffstats
path: root/api4/channel_test.go
diff options
context:
space:
mode:
authorRobin Naundorf <r.naundorf@fh-muenster.de>2017-05-09 14:52:46 +0200
committerJoram Wilander <jwawilander@gmail.com>2017-05-09 07:52:46 -0500
commit5efcd2d9d3fb91ae7475918b807b7947b533da9b (patch)
tree7f1c0bfe5ca751b27b6a520f63cd20e280377d85 /api4/channel_test.go
parent530814b8c9b1b47dd6eb05e70548c61d75da9a23 (diff)
downloadchat-5efcd2d9d3fb91ae7475918b807b7947b533da9b.tar.gz
chat-5efcd2d9d3fb91ae7475918b807b7947b533da9b.tar.bz2
chat-5efcd2d9d3fb91ae7475918b807b7947b533da9b.zip
Add API Endpoint for deleted Channels (#5889)
Diffstat (limited to 'api4/channel_test.go')
-rw-r--r--api4/channel_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/api4/channel_test.go b/api4/channel_test.go
index 345bbefaf..10cb272f3 100644
--- a/api4/channel_test.go
+++ b/api4/channel_test.go
@@ -489,6 +489,55 @@ func TestGetChannel(t *testing.T) {
CheckNotFoundStatus(t, resp)
}
+func TestGetDeletedChannelsForTeam(t *testing.T) {
+ th := Setup().InitBasic().InitSystemAdmin()
+ defer TearDown()
+ Client := th.Client
+ team := th.BasicTeam
+
+ channels, resp := Client.GetDeletedChannelsForTeam(team.Id, 0, 100, "")
+ CheckForbiddenStatus(t, resp)
+
+ th.LoginTeamAdmin()
+
+ channels, resp = Client.GetDeletedChannelsForTeam(team.Id, 0, 100, "")
+ CheckNoError(t, resp)
+ if len(*channels) != 0 {
+ t.Fatal("should be no deleted channels")
+ }
+
+ // create and delete public channel
+ publicChannel1 := th.CreatePublicChannel()
+ Client.DeleteChannel(publicChannel1.Id)
+
+ channels, resp = Client.GetDeletedChannelsForTeam(team.Id, 0, 100, "")
+ CheckNoError(t, resp)
+ if len(*channels) != 1 {
+ t.Fatal("should be 1 deleted channel")
+ }
+
+ publicChannel2 := th.CreatePublicChannel()
+ Client.DeleteChannel(publicChannel2.Id)
+
+ channels, resp = Client.GetDeletedChannelsForTeam(team.Id, 0, 100, "")
+ CheckNoError(t, resp)
+ if len(*channels) != 2 {
+ t.Fatal("should be 2 deleted channels")
+ }
+
+ channels, resp = Client.GetDeletedChannelsForTeam(team.Id, 0, 1, "")
+ CheckNoError(t, resp)
+ if len(*channels) != 1 {
+ t.Fatal("should be one channel per page")
+ }
+
+ channels, resp = Client.GetDeletedChannelsForTeam(team.Id, 1, 1, "")
+ CheckNoError(t, resp)
+ if len(*channels) != 1 {
+ t.Fatal("should be one channel per page")
+ }
+}
+
func TestGetPublicChannelsForTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer TearDown()