test+refactor: audit-row assertions + uniform PATCH rollback (review follow-ups)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 21:04:09 +02:00
parent c9120848f5
commit 27caaa9787
3 changed files with 42 additions and 5 deletions
+20 -2
View File
@@ -1,6 +1,7 @@
use db::{Db, catalog, fields, vocab};
use db::{Db, audit, catalog, fields, vocab};
use domain::{
AuditActor, FieldType, LocalizedLabel, NewFieldDefinition, NewTerm, ObjectInput, Visibility,
AuditAction, AuditActor, FieldType, LocalizedLabel, NewFieldDefinition, NewTerm, ObjectInput,
Visibility,
};
use sqlx::PgPool;
@@ -222,6 +223,15 @@ async fn update_term_changes_labels_and_uri(pool: PgPool) {
.await
.unwrap();
assert!(existed);
let history = audit::history_for(&mut *tx, "term", term_id.to_uuid())
.await
.unwrap();
assert!(
history.iter().any(|e| e.action == AuditAction::Updated),
"expected an Updated audit entry for the term"
);
tx.commit().await.unwrap();
let term = vocab::term_by_id(db.pool(), term_id)
@@ -308,6 +318,14 @@ async fn delete_term_blocks_when_referenced_then_succeeds(pool: PgPool) {
.is_none()
);
let history = audit::history_for(&mut *tx, "term", term_id.to_uuid())
.await
.unwrap();
assert!(
history.iter().any(|e| e.action == AuditAction::Deleted),
"expected a Deleted audit entry for the term"
);
let gone = vocab::delete_term(&mut tx, AuditActor::System, vocab.id, term_id)
.await
.unwrap();