Skip to content

Commit 6a7d1ce

Browse files
committed
More tests
1 parent 17d9688 commit 6a7d1ce

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

coderd/insights_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,37 @@ func TestUserLatencyInsights_BadRequest(t *testing.T) {
240240
assert.Error(t, err, "want error for end time partial day when not today")
241241
}
242242

243+
func TestUserActivityInsights_BadRequest(t *testing.T) {
244+
t.Parallel()
245+
246+
saoPaulo, err := time.LoadLocation("America/Sao_Paulo")
247+
require.NoError(t, err)
248+
y, m, d := time.Now().UTC().Date()
249+
today := time.Date(y, m, d, 0, 0, 0, 0, saoPaulo)
250+
251+
// Prepare
252+
253+
client := coderdtest.New(t, &coderdtest.Options{})
254+
_ = coderdtest.CreateFirstUser(t, client)
255+
256+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
257+
defer cancel()
258+
259+
// Test insights request
260+
_, err = client.UserActivityInsights(ctx, codersdk.UserActivityInsightsRequest{
261+
StartTime: today,
262+
EndTime: today.AddDate(0, 0, -1),
263+
})
264+
assert.Error(t, err, "want error for end time before start time")
265+
266+
// Test insights request
267+
_, err = client.UserActivityInsights(ctx, codersdk.UserActivityInsightsRequest{
268+
StartTime: today.AddDate(0, 0, -7),
269+
EndTime: today.Add(-time.Hour),
270+
})
271+
assert.Error(t, err, "want error for end time partial day when not today")
272+
}
273+
243274
func TestTemplateInsights_Golden(t *testing.T) {
244275
t.Parallel()
245276

0 commit comments

Comments
 (0)