[MM-45052] Add error checking in insights API (#21048)

Этот коммит содержится в:
cyrilzhang-mm
2022-10-20 14:37:24 -04:00
коммит произвёл GitHub
родитель 09f63eec06
Коммит 093c657e56
6 изменённых файлов: 102 добавлений и 16 удалений

Просмотреть файл

@@ -230,6 +230,12 @@ func TestGetTopReactionsForTeamSince(t *testing.T) {
CheckNotFoundStatus(t, resp)
})
t.Run("get-top-reactions-for-team-since invalid time range", func(t *testing.T) {
_, resp, err := client.GetTopReactionsForTeamSince(teamId, "7_days", 0, 5)
require.Error(t, err)
CheckBadRequestStatus(t, resp)
})
t.Run("get-top-reactions-for-team-since not a member of team", func(t *testing.T) {
th.UnlinkUserFromTeam(th.BasicUser, th.BasicTeam)
_, resp, err := client.GetTopReactionsForTeamSince(teamId, model.TimeRangeToday, 0, 5)
@@ -417,6 +423,12 @@ func TestGetTopReactionsForUserSince(t *testing.T) {
CheckNotFoundStatus(t, resp)
})
t.Run("get-top-reactions-for-user-since invalid time range", func(t *testing.T) {
_, resp, err := client.GetTopReactionsForUserSince(teamId, "7_days", 0, 5)
require.Error(t, err)
CheckBadRequestStatus(t, resp)
})
t.Run("get-top-reactions-for-user-since not a member of team", func(t *testing.T) {
th.UnlinkUserFromTeam(th.BasicUser, th.BasicTeam)
_, resp, err := client.GetTopReactionsForUserSince(teamId, model.TimeRangeToday, 0, 5)
@@ -515,6 +527,12 @@ func TestGetTopChannelsForTeamSince(t *testing.T) {
CheckNotFoundStatus(t, resp)
})
t.Run("get-top-channels-for-team-since invalid time range", func(t *testing.T) {
_, resp, err := client.GetTopChannelsForTeamSince(teamId, "7_days", 0, 5)
assert.Error(t, err)
CheckBadRequestStatus(t, resp)
})
t.Run("get-top-channels-for-team-since not a member of team", func(t *testing.T) {
th.UnlinkUserFromTeam(th.BasicUser, th.BasicTeam)
_, resp, err := client.GetTopChannelsForTeamSince(teamId, model.TimeRangeToday, 0, 5)
@@ -592,6 +610,12 @@ func TestGetTopChannelsForUserSince(t *testing.T) {
CheckNotFoundStatus(t, resp)
})
t.Run("get-top-channels-for-user-since invalid time range", func(t *testing.T) {
_, resp, err := client.GetTopChannelsForUserSince(teamId, "7_days", 0, 5)
assert.Error(t, err)
CheckBadRequestStatus(t, resp)
})
t.Run("get-top-channels-for-user-since not a member of team", func(t *testing.T) {
th.UnlinkUserFromTeam(th.BasicUser, th.BasicTeam)
_, resp, err := client.GetTopChannelsForUserSince(teamId, model.TimeRangeToday, 0, 5)