test(db): cover SQLite reaction parity

Signed-off-by: npub13n66s06epmqf2kc3v373ez8hj65cuzyvxzjf93vwpervxqn2u7jq2qd9je <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@buzz.block.builderlab.xyz>
This commit is contained in:
npub13n66s06epmqf2kc3v373ez8hj65cuzyvxzjf93vwpervxqn2u7jq2qd9je
2026-08-01 12:48:41 -04:00
committed by Brother Darryl
parent efadcd1ef6
commit 8580a59d9e

View File

@@ -1559,6 +1559,74 @@ mod tests {
std::fs::remove_file(path).unwrap();
}
#[tokio::test]
async fn reaction_helpers_preserve_dedupe_aggregation_and_tenant_scope() {
let pool = connect("sqlite::memory:").await.unwrap();
let community = ensure_configured_community(&pool, "reactions.example")
.await
.unwrap()
.id;
let foreign = ensure_configured_community(&pool, "foreign.example")
.await
.unwrap()
.id;
let target = vec![1_u8; 32];
let actor = vec![2_u8; 32];
let source = vec![3_u8; 32];
let at = chrono::DateTime::from_timestamp(100, 0).unwrap();
assert!(
add_reaction(&pool, community, &target, at, &actor, "👍", None)
.await
.unwrap()
);
assert!(
!add_reaction(&pool, community, &target, at, &actor, "👍", None)
.await
.unwrap()
);
assert!(
set_reaction_event_id(&pool, community, &target, at, &actor, "👍", &source)
.await
.unwrap()
);
assert_eq!(
get_active_reaction_record(&pool, community, &target, at, &actor, "👍")
.await
.unwrap()
.unwrap()
.reaction_event_id,
Some(source)
);
let groups = get_reactions(&pool, community, &target, at, 10, None)
.await
.unwrap();
assert_eq!(groups.len(), 1);
assert_eq!(groups[0].count, 1);
assert!(get_reactions(&pool, foreign, &target, at, 10, None)
.await
.unwrap()
.is_empty());
assert_eq!(
get_reactions_bulk(&pool, community, &[(&target, at)])
.await
.unwrap()
.len(),
1
);
assert!(remove_reaction(&pool, community, &target, at, &actor, "👍")
.await
.unwrap());
assert!(get_reactions(&pool, community, &target, at, 10, None)
.await
.unwrap()
.is_empty());
assert!(
add_reaction(&pool, community, &target, at, &actor, "👍", None)
.await
.unwrap()
);
}
#[tokio::test]
async fn core_slice_survives_temporary_file_reopen() {
let path = std::env::temp_dir().join(format!("buzz-db-{}.sqlite", Uuid::new_v4()));