Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
madchicken committed Jan 6, 2025
1 parent b7b9889 commit 6d4cd66
Showing 1 changed file with 77 additions and 30 deletions.
107 changes: 77 additions & 30 deletions lib/tests/use_default_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,93 @@ async fn use_default_db() {
};
let graph = neo4j.graph();

let default_db = graph
.execute_on("system", query("SHOW DEFAULT DATABASE"), Operation::Read)
.await
.unwrap()
.column_into_stream::<String>("name")
.try_fold(None::<String>, |acc, db| async { Ok(acc.or(Some(db))) })
.await
.unwrap()
.unwrap();
#[cfg(feature = "unstable-bolt-protocol-impl-v2")]
{
let default_db = graph
.execute_on("system", query("SHOW DEFAULT DATABASE"), Operation::Read)
.await
.unwrap()
.column_into_stream::<String>("name")
.try_fold(None::<String>, |acc, db| async { Ok(acc.or(Some(db))) })
.await
.unwrap()
.unwrap();

if default_db != dbname {
eprintln!(
concat!(
"Skipping test: The test must run against a testcontainer ",
"or have `{}` configured as the default database"
),
dbname
);
return;
}
}
#[cfg(not(feature = "unstable-bolt-protocol-impl-v2"))]
{
let default_db = graph
.execute_on("system", query("SHOW DEFAULT DATABASE"))
.await
.unwrap()
.column_into_stream::<String>("name")
.try_fold(None::<String>, |acc, db| async { Ok(acc.or(Some(db))) })
.await
.unwrap()
.unwrap();

if default_db != dbname {
eprintln!(
concat!(
if default_db != dbname {
eprintln!(
concat!(
"Skipping test: The test must run against a testcontainer ",
"or have `{}` configured as the default database"
),
dbname
);
return;
),
dbname
);
return;
}
}


let id = uuid::Uuid::new_v4();
graph
.run(query("CREATE (:Node { uuid: $uuid })").param("uuid", id.to_string()))
.await
.unwrap();
#[cfg(feature = "unstable-bolt-protocol-impl-v2")]
{
let count = graph
.execute_on(
dbname.as_str(),
query("MATCH (n:Node {uuid: $uuid}) RETURN count(n) AS result")
.param("uuid", id.to_string()),
Operation::Read,
)
.await
.unwrap()
.column_into_stream::<u64>("result")
.try_fold(0, |sum, count| async move { Ok(sum + count) })
.await
.unwrap();

let count = graph
.execute_on(
dbname.as_str(),
query("MATCH (n:Node {uuid: $uuid}) RETURN count(n) AS result")
.param("uuid", id.to_string()),
Operation::Read,
)
.await
.unwrap()
.column_into_stream::<u64>("result")
.try_fold(0, |sum, count| async move { Ok(sum + count) })
.await
.unwrap();
assert_eq!(count, 1);
}

assert_eq!(count, 1);
#[cfg(not(feature = "unstable-bolt-protocol-impl-v2"))]
{
let count = graph
.execute_on(
dbname.as_str(),
query("MATCH (n:Node {uuid: $uuid}) RETURN count(n) AS result")
.param("uuid", id.to_string())
)
.await
.unwrap()
.column_into_stream::<u64>("result")
.try_fold(0, |sum, count| async move { Ok(sum + count) })
.await
.unwrap();

assert_eq!(count, 1);
}
}

0 comments on commit 6d4cd66

Please sign in to comment.