feat: with tx on all

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-10-03 23:08:12 +02:00
parent e774529b04
commit bc28451f8d
18 changed files with 256 additions and 28 deletions

View File

@@ -0,0 +1,8 @@
use crunch_postgres::PostgresPersistence;
#[tokio::test]
async fn test_new_from_env() -> anyhow::Result<()> {
PostgresPersistence::new_from_env().await?;
Ok(())
}

View File

@@ -0,0 +1,63 @@
use crunch_postgres::PostgresPersistence;
use crunch_traits::{EventInfo, Persistence};
#[tokio::test]
async fn test_persistence_insert() -> anyhow::Result<()> {
let persistence = PostgresPersistence::new_from_env().await?;
persistence
.insert(
&EventInfo {
domain: "some-domain",
entity_type: "some-entity-type",
event_name: "some-event-name",
},
b"some-strange-and-cruncy-content".to_vec(),
)
.await?;
persistence
.insert(
&EventInfo {
domain: "some-domain",
entity_type: "some-entity-type",
event_name: "some-event-name",
},
b"some-strange-and-cruncy-content".to_vec(),
)
.await?;
Ok(())
}
#[tokio::test]
async fn test_persistence_next() -> anyhow::Result<()> {
let persistence = PostgresPersistence::new_from_env().await?;
persistence
.insert(
&EventInfo {
domain: "some-domain",
entity_type: "some-entity-type",
event_name: "some-event-name",
},
b"some-strange-and-cruncy-content".to_vec(),
)
.await?;
persistence
.insert(
&EventInfo {
domain: "some-domain",
entity_type: "some-entity-type",
event_name: "some-event-name",
},
b"some-strange-and-cruncy-content".to_vec(),
)
.await?;
assert!(persistence.next().await?.is_some());
assert!(persistence.next().await?.is_some());
Ok(())
}