Lines
100 %
Functions
Branches
use sqlx::PgPool;
use supp_macro::local_db_sqlx_test;
use super::*;
use crate::db::install_test_pool;
use crate::lossless::seed;
async fn setup() {}
#[local_db_sqlx_test]
async fn a_snapshot_holds_everything_of_the_transaction(pool: PgPool) -> anyhow::Result<()> {
let fixture = seed(&pool).await?;
let user = User { id: fixture.user };
let Some(snapshot) = user.transaction_snapshot(fixture.transaction).await? else {
anyhow::bail!("the seeded transaction is missing");
};
assert_eq!(snapshot.transaction.id, fixture.transaction);
assert_eq!(snapshot.splits.len(), 4);
assert_eq!(snapshot.split_tags.len(), snapshot.splits.len());
assert!(!snapshot.tags.is_empty());
let splits = user.get_transaction_splits(fixture.transaction).await?;
assert_eq!(
snapshot.splits.iter().map(|s| s.id).collect::<Vec<_>>(),
splits.iter().map(|s| s.id).collect::<Vec<_>>()
);
}
async fn a_missing_transaction_has_no_snapshot(pool: PgPool) -> anyhow::Result<()> {
assert!(user.transaction_snapshot(Uuid::new_v4()).await?.is_none());