Skip to content

Commit 18f6bbf

Browse files
committed
add unit test
1 parent ebea5ba commit 18f6bbf

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

coderd/database/querier_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,29 @@ func TestDefaultOrg(t *testing.T) {
516516
require.True(t, all[0].IsDefault, "first org should always be default")
517517
}
518518

519+
func TestAuditLogDefaultLimit(t *testing.T) {
520+
t.Parallel()
521+
if testing.Short() {
522+
t.SkipNow()
523+
}
524+
525+
sqlDB := testSQLDB(t)
526+
err := migrations.Up(sqlDB)
527+
require.NoError(t, err)
528+
db := database.New(sqlDB)
529+
530+
for i := 0; i < 110; i++ {
531+
dbgen.AuditLog(t, db, database.AuditLog{})
532+
}
533+
534+
ctx := testutil.Context(t, testutil.WaitShort)
535+
rows, err := db.GetAuditLogsOffset(ctx, database.GetAuditLogsOffsetParams{})
536+
require.NoError(t, err)
537+
// The length should match the default limit of the SQL query.
538+
// Updating the sql query requires changing the number below to match.
539+
require.Len(t, rows, 100)
540+
}
541+
519542
// TestReadCustomRoles tests the input params returns the correct set of roles.
520543
func TestReadCustomRoles(t *testing.T) {
521544
t.Parallel()

0 commit comments

Comments
 (0)