From 25b9b7d26b8738343d269c83031ba5a5408d0d58 Mon Sep 17 00:00:00 2001 From: Andrei Stanciu Date: Tue, 28 Feb 2017 17:47:30 +0200 Subject: ApiV4: GET /users/{user_id}/teams/unread (#5539) --- api4/team_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'api4/team_test.go') diff --git a/api4/team_test.go b/api4/team_test.go index a4ec1a6e2..e54cf4414 100644 --- a/api4/team_test.go +++ b/api4/team_test.go @@ -463,3 +463,34 @@ func TestUpdateTeamMemberRoles(t *testing.T) { _, resp = Client.UpdateTeamMemberRoles(th.BasicTeam.Id, th.BasicUser.Id, TEAM_MEMBER) CheckNoError(t, resp) } + +func TestGetMyTeamsUnread(t *testing.T) { + th := Setup().InitBasic().InitSystemAdmin() + defer TearDown() + Client := th.Client + + user := th.BasicUser + Client.Login(user.Email, user.Password) + + teams, resp := Client.GetTeamsUnreadForUser(user.Id, "") + CheckNoError(t, resp) + if len(teams) == 0 { + t.Fatal("should have results") + } + + teams, resp = Client.GetTeamsUnreadForUser(user.Id, th.BasicTeam.Id) + CheckNoError(t, resp) + if len(teams) != 0 { + t.Fatal("should not have results") + } + + _, resp = Client.GetTeamsUnreadForUser("fail", "") + CheckBadRequestStatus(t, resp) + + _, resp = Client.GetTeamsUnreadForUser(model.NewId(), "") + CheckForbiddenStatus(t, resp) + + Client.Logout() + _, resp = Client.GetTeamsUnreadForUser(user.Id, "") + CheckUnauthorizedStatus(t, resp) +} \ No newline at end of file -- cgit v1.2.3-1-g7c22