Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix database fake and expect
  • Loading branch information
BrunoQuaresma committed Sep 15, 2022
commit 3f23deb0d070237f5bd5b25498d523ab6f1dce9d
4 changes: 2 additions & 2 deletions coderd/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ func TestAuditLogsFilter(t *testing.T) {
SearchQuery: "action:create",
})
require.NoError(t, err)
require.Len(t, actionCreateLogs, 2)
require.Len(t, actionCreateLogs.AuditLogs, 2)

// Verify the number of delete logs
actionDeleteLogs, err := client.AuditLogs(ctx, codersdk.AuditLogsRequest{
SearchQuery: "action:delete",
})
require.NoError(t, err)
require.Len(t, actionDeleteLogs, 1)
require.Len(t, actionDeleteLogs.AuditLogs, 1)
})
}
8 changes: 8 additions & 0 deletions coderd/database/databasefake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -2337,6 +2337,14 @@ func (q *fakeQuerier) GetAuditLogsOffset(ctx context.Context, arg database.GetAu
continue
}

if arg.Action != "" && !strings.Contains(strings.ToLower(string(alog.Action)), strings.ToLower(arg.Action)) {
continue
}

if arg.ResourceType != "" && !strings.Contains(strings.ToLower(string(alog.ResourceType)), strings.ToLower(arg.ResourceType)) {
continue
}

user, err := q.GetUserByID(ctx, alog.UserID)
userValid := err == nil

Expand Down