(t *testing.T)
| 236 | } |
| 237 | |
| 238 | func TestUpdateLastUsed_Success(t *testing.T) { |
| 239 | db, mock, err := sqlmock.New() |
| 240 | assert.NoError(t, err) |
| 241 | defer func() { _ = db.Close() }() |
| 242 | |
| 243 | ds := Datasource{Conn: db} |
| 244 | |
| 245 | apiKeyID := "api_key_123" |
| 246 | |
| 247 | mock.ExpectExec("UPDATE ledgerforge.api_keys SET last_used_at = \\$1 WHERE api_key_id = \\$2"). |
| 248 | WithArgs(sqlmock.AnyArg(), apiKeyID). |
| 249 | WillReturnResult(sqlmock.NewResult(1, 1)) |
| 250 | |
| 251 | err = ds.UpdateLastUsed(context.Background(), apiKeyID) |
| 252 | assert.NoError(t, err) |
| 253 | |
| 254 | err = mock.ExpectationsWereMet() |
| 255 | assert.NoError(t, err) |
| 256 | } |
| 257 | |
| 258 | func TestUpdateLastUsed_DatabaseError(t *testing.T) { |
| 259 | db, mock, err := sqlmock.New() |
nothing calls this directly
no test coverage detected