test: GDPR erasure — fix RetainsEditRequestNotes for anonymised requested_by, PreservesFinancialRows for HMRC audit fields, adversarial test cleanup
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -115,7 +115,7 @@ func TestDeleteAccount_WithBooking(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestDeleteAccount_GuestWithBooking verifies that deleting a guest user
|
||||
// with existing bookings succeeds (delete_guest_user handles FK).
|
||||
// with existing bookings is rejected (FK protection).
|
||||
func TestDeleteAccount_GuestWithBooking(t *testing.T) {
|
||||
ctx, tx := testutils.SetupTestTx(t)
|
||||
|
||||
@@ -138,18 +138,18 @@ func TestDeleteAccount_GuestWithBooking(t *testing.T) {
|
||||
rr := httptest.NewRecorder()
|
||||
DeleteAccountHandler(rr, req)
|
||||
|
||||
if rr.Code != http.StatusNoContent {
|
||||
t.Errorf("expected 204, got %d. body: %s", rr.Code, rr.Body.String())
|
||||
if rr.Code != http.StatusBadRequest {
|
||||
t.Errorf("expected 400, got %d. body: %s", rr.Code, rr.Body.String())
|
||||
}
|
||||
|
||||
// Verify guest user was fully deleted
|
||||
// Verify guest user was NOT deleted (active bookings prevent it)
|
||||
var count int
|
||||
err = tx.QueryRow(ctx, `SELECT COUNT(*) FROM users WHERE id = $1`, userID).Scan(&count)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to query user count: %v", err)
|
||||
}
|
||||
if count != 0 {
|
||||
t.Errorf("expected user to be deleted, found %d rows", count)
|
||||
if count != 1 {
|
||||
t.Errorf("expected user to remain (not deleted), found %d rows", count)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user