summaryrefslogtreecommitdiffstats
path: root/api4/team_test.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-04-04 02:35:29 +0900
committerCorey Hulen <corey@hulen.com>2017-04-03 10:35:29 -0700
commit997eacd4b635a2a7a86eadeeb2b229f153c52626 (patch)
treef9e517fba61ab4aa3c30e9ac1d7ea26310ad1589 /api4/team_test.go
parent43e795448f62fa86f3dad7940fc2297c44a6ea9c (diff)
downloadchat-997eacd4b635a2a7a86eadeeb2b229f153c52626.tar.gz
chat-997eacd4b635a2a7a86eadeeb2b229f153c52626.tar.bz2
chat-997eacd4b635a2a7a86eadeeb2b229f153c52626.zip
APIv4 DELETE /teams/{team_id} (#5937)
Diffstat (limited to 'api4/team_test.go')
-rw-r--r--api4/team_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/api4/team_test.go b/api4/team_test.go
index 227b0958b..86160fb6f 100644
--- a/api4/team_test.go
+++ b/api4/team_test.go
@@ -321,6 +321,48 @@ func TestPatchTeam(t *testing.T) {
CheckNoError(t, resp)
}
+func TestSoftDeleteTeam(t *testing.T) {
+ th := Setup().InitBasic().InitSystemAdmin()
+ defer TearDown()
+ Client := th.Client
+
+ team := &model.Team{DisplayName: "DisplayName", Name: GenerateTestTeamName(), Email: GenerateTestEmail(), Type: model.TEAM_OPEN}
+ team, _ = Client.CreateTeam(team)
+
+ ok, resp := Client.SoftDeleteTeam(team.Id)
+ CheckNoError(t, resp)
+
+ if !ok {
+ t.Fatal("should have returned true")
+ }
+
+ rteam, err := app.GetTeam(team.Id)
+ if err != nil {
+ t.Fatal("should have returned archived team")
+ }
+ if rteam.DeleteAt == 0 {
+ t.Fatal("should have not set to zero")
+ }
+
+ ok, resp = Client.SoftDeleteTeam("junk")
+ CheckBadRequestStatus(t, resp)
+
+ if ok {
+ t.Fatal("should have returned false")
+ }
+
+ otherTeam := th.BasicTeam
+ _, resp = Client.SoftDeleteTeam(otherTeam.Id)
+ CheckForbiddenStatus(t, resp)
+
+ Client.Logout()
+ _, resp = Client.SoftDeleteTeam(otherTeam.Id)
+ CheckUnauthorizedStatus(t, resp)
+
+ _, resp = th.SystemAdminClient.SoftDeleteTeam(otherTeam.Id)
+ CheckNoError(t, resp)
+}
+
func TestGetAllTeams(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer TearDown()