mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: add unit test that deletes abandoned workspace (#7990)
* test: add unit test that deletes abandoned workspace This is to ensure we do not break this functionality in future. This is important incase this edge case happens, an admin can clean up the abandoned resources.
This commit is contained in:
@@ -4646,11 +4646,19 @@ func (q *fakeQuerier) UpdateUserDeletedByID(_ context.Context, params database.U
|
||||
u.Deleted = params.Deleted
|
||||
q.users[i] = u
|
||||
// NOTE: In the real world, this is done by a trigger.
|
||||
for i, k := range q.apiKeys {
|
||||
i := 0
|
||||
for {
|
||||
if i >= len(q.apiKeys) {
|
||||
break
|
||||
}
|
||||
k := q.apiKeys[i]
|
||||
if k.UserID == u.ID {
|
||||
q.apiKeys[i] = q.apiKeys[len(q.apiKeys)-1]
|
||||
q.apiKeys = q.apiKeys[:len(q.apiKeys)-1]
|
||||
// We removed an element, so decrement
|
||||
i--
|
||||
}
|
||||
i++
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user