Skip to content

Commit 77880f1

Browse files
committed
add deleteapikeybyid to databasefake
1 parent 5c062df commit 77880f1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

coderd/database/databasefake/databasefake.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ func (q *fakeQuerier) GetAPIKeyByID(_ context.Context, id string) (database.APIK
126126
return database.APIKey{}, sql.ErrNoRows
127127
}
128128

129+
func (q *fakeQuerier) DeleteAPIKeyByID(_ context.Context, id string) error {
130+
q.mutex.Lock()
131+
defer q.mutex.Unlock()
132+
133+
for index, apiKey := range q.apiKeys {
134+
if apiKey.ID != id {
135+
continue
136+
}
137+
q.apiKeys[index] = q.apiKeys[len(q.apiKeys)-1]
138+
q.apiKeys = q.apiKeys[:len(q.apiKeys)-1]
139+
return nil
140+
}
141+
return sql.ErrNoRows
142+
}
143+
129144
func (q *fakeQuerier) GetFileByHash(_ context.Context, hash string) (database.File, error) {
130145
q.mutex.RLock()
131146
defer q.mutex.RUnlock()

0 commit comments

Comments
 (0)