Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0587a91

Browse files
committed
Fix CountAuthorizedAuditLogs query impl
1 parent dad1a28 commit 0587a91

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

coderd/database/dbauthz/setup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func (s *MethodTestSuite) NotAuthorizedErrorTest(ctx context.Context, az *coderd
296296
resp, err := callMethod(ctx)
297297

298298
// This is unfortunate, but if we are using `Filter` the error returned will be nil. So filter out
299-
// any case where the error is nil and the response is an empty slice.
299+
// any case where the error is nil and the response is an empty slice or int64(0).
300300
if err != nil || !hasEmptyResponse(resp) {
301301
if testCase.cancelledCtxExpect == "" {
302302
s.Errorf(err, "method should an error with cancellation")

coderd/database/modelqueries.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,9 @@ func (q *sqlQuerier) CountAuthorizedAuditLogs(ctx context.Context, arg CountAudi
598598
defer rows.Close()
599599
var count int64
600600
for rows.Next() {
601-
count++
601+
if err := rows.Scan(&count); err != nil {
602+
return 0, err
603+
}
602604
}
603605
if err := rows.Close(); err != nil {
604606
return 0, err

0 commit comments

Comments
 (0)