summaryrefslogtreecommitdiffstats
path: root/api4/channel_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'api4/channel_test.go')
-rw-r--r--api4/channel_test.go77
1 files changed, 63 insertions, 14 deletions
diff --git a/api4/channel_test.go b/api4/channel_test.go
index c2c1bcf56..b4f08dc37 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()
@@ -499,11 +548,11 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
channels, resp := Client.GetPublicChannelsForTeam(team.Id, 0, 100, "")
CheckNoError(t, resp)
- if len(*channels) != 4 {
+ if len(channels) != 4 {
t.Fatal("wrong length")
}
- for i, c := range *channels {
+ for i, c := range channels {
if c.Type != model.CHANNEL_OPEN {
t.Fatal("should include open channel only")
}
@@ -518,11 +567,11 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
privateChannel := th.CreatePrivateChannel()
channels, resp = Client.GetPublicChannelsForTeam(team.Id, 0, 100, "")
CheckNoError(t, resp)
- if len(*channels) != 4 {
+ if len(channels) != 4 {
t.Fatal("wrong length")
}
- for _, c := range *channels {
+ for _, c := range channels {
if c.Type != model.CHANNEL_OPEN {
t.Fatal("should not include private channel")
}
@@ -534,19 +583,19 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
channels, resp = Client.GetPublicChannelsForTeam(team.Id, 0, 1, "")
CheckNoError(t, resp)
- if len(*channels) != 1 {
+ if len(channels) != 1 {
t.Fatal("should be one channel per page")
}
channels, resp = Client.GetPublicChannelsForTeam(team.Id, 1, 1, "")
CheckNoError(t, resp)
- if len(*channels) != 1 {
+ if len(channels) != 1 {
t.Fatal("should be one channel per page")
}
channels, resp = Client.GetPublicChannelsForTeam(team.Id, 10000, 100, "")
CheckNoError(t, resp)
- if len(*channels) != 0 {
+ if len(channels) != 0 {
t.Fatal("should be no channel")
}
@@ -580,11 +629,11 @@ func TestGetPublicChannelsByIdsForTeam(t *testing.T) {
channels, resp := Client.GetPublicChannelsByIdsForTeam(teamId, input)
CheckNoError(t, resp)
- if len(*channels) != 1 {
+ if len(channels) != 1 {
t.Fatal("should return 1 channel")
}
- if (*channels)[0].DisplayName != output[0] {
+ if (channels)[0].DisplayName != output[0] {
t.Fatal("missing channel")
}
@@ -597,11 +646,11 @@ func TestGetPublicChannelsByIdsForTeam(t *testing.T) {
channels, resp = Client.GetPublicChannelsByIdsForTeam(teamId, input)
CheckNoError(t, resp)
- if len(*channels) != 2 {
+ if len(channels) != 2 {
t.Fatal("should return 2 channels")
}
- for i, c := range *channels {
+ for i, c := range channels {
if c.DisplayName != output[i] {
t.Fatal("missing channel")
}
@@ -640,7 +689,7 @@ func TestGetChannelsForTeamForUser(t *testing.T) {
CheckNoError(t, resp)
found := make([]bool, 3)
- for _, c := range *channels {
+ for _, c := range channels {
if c.Id == th.BasicChannel.Id {
found[0] = true
} else if c.Id == th.BasicChannel2.Id {
@@ -690,7 +739,7 @@ func TestSearchChannels(t *testing.T) {
CheckNoError(t, resp)
found := false
- for _, c := range *channels {
+ for _, c := range channels {
if c.Type != model.CHANNEL_OPEN {
t.Fatal("should only return public channels")
}
@@ -709,7 +758,7 @@ func TestSearchChannels(t *testing.T) {
CheckNoError(t, resp)
found = false
- for _, c := range *channels {
+ for _, c := range channels {
if c.Id == th.BasicPrivateChannel.Id {
found = true
}