test(db): cover delete/empty-changes/empty-history; clarify map_row naming

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-02 07:56:05 +02:00
parent 87b016a56c
commit c67b588188
2 changed files with 39 additions and 3 deletions
+35
View File
@@ -68,3 +68,38 @@ async fn history_is_scoped_to_one_entity(pool: PgPool) {
assert_eq!(only_a.len(), 1);
assert_eq!(only_a[0].entity_id, a);
}
#[sqlx::test]
async fn deleted_action_with_empty_changes_round_trips(pool: PgPool) {
let db = Db::from_pool(pool);
let id = Uuid::new_v4();
audit::record(
db.pool(),
&NewAuditEvent {
actor: AuditActor::System,
action: AuditAction::Deleted,
entity_type: "object".into(),
entity_id: id,
changes: vec![],
},
)
.await
.unwrap();
let history = audit::history_for(db.pool(), "object", id).await.unwrap();
assert_eq!(history.len(), 1);
assert_eq!(history[0].action, AuditAction::Deleted);
assert!(history[0].changes.is_empty());
}
#[sqlx::test]
async fn history_is_empty_for_unknown_entity(pool: PgPool) {
let db = Db::from_pool(pool);
let history = audit::history_for(db.pool(), "object", Uuid::new_v4())
.await
.unwrap();
assert!(history.is_empty());
}