Skip to content

Commit 6d4cd66

Browse files
committed
Fix integration tests
1 parent b7b9889 commit 6d4cd66

File tree

1 file changed

+77
-30
lines changed

1 file changed

+77
-30
lines changed

lib/tests/use_default_db.rs

+77-30
Original file line numberDiff line numberDiff line change
@@ -25,46 +25,93 @@ async fn use_default_db() {
2525
};
2626
let graph = neo4j.graph();
2727

28-
let default_db = graph
29-
.execute_on("system", query("SHOW DEFAULT DATABASE"), Operation::Read)
30-
.await
31-
.unwrap()
32-
.column_into_stream::<String>("name")
33-
.try_fold(None::<String>, |acc, db| async { Ok(acc.or(Some(db))) })
34-
.await
35-
.unwrap()
36-
.unwrap();
28+
#[cfg(feature = "unstable-bolt-protocol-impl-v2")]
29+
{
30+
let default_db = graph
31+
.execute_on("system", query("SHOW DEFAULT DATABASE"), Operation::Read)
32+
.await
33+
.unwrap()
34+
.column_into_stream::<String>("name")
35+
.try_fold(None::<String>, |acc, db| async { Ok(acc.or(Some(db))) })
36+
.await
37+
.unwrap()
38+
.unwrap();
39+
40+
if default_db != dbname {
41+
eprintln!(
42+
concat!(
43+
"Skipping test: The test must run against a testcontainer ",
44+
"or have `{}` configured as the default database"
45+
),
46+
dbname
47+
);
48+
return;
49+
}
50+
}
51+
#[cfg(not(feature = "unstable-bolt-protocol-impl-v2"))]
52+
{
53+
let default_db = graph
54+
.execute_on("system", query("SHOW DEFAULT DATABASE"))
55+
.await
56+
.unwrap()
57+
.column_into_stream::<String>("name")
58+
.try_fold(None::<String>, |acc, db| async { Ok(acc.or(Some(db))) })
59+
.await
60+
.unwrap()
61+
.unwrap();
3762

38-
if default_db != dbname {
39-
eprintln!(
40-
concat!(
63+
if default_db != dbname {
64+
eprintln!(
65+
concat!(
4166
"Skipping test: The test must run against a testcontainer ",
4267
"or have `{}` configured as the default database"
43-
),
44-
dbname
45-
);
46-
return;
68+
),
69+
dbname
70+
);
71+
return;
72+
}
4773
}
4874

75+
4976
let id = uuid::Uuid::new_v4();
5077
graph
5178
.run(query("CREATE (:Node { uuid: $uuid })").param("uuid", id.to_string()))
5279
.await
5380
.unwrap();
81+
#[cfg(feature = "unstable-bolt-protocol-impl-v2")]
82+
{
83+
let count = graph
84+
.execute_on(
85+
dbname.as_str(),
86+
query("MATCH (n:Node {uuid: $uuid}) RETURN count(n) AS result")
87+
.param("uuid", id.to_string()),
88+
Operation::Read,
89+
)
90+
.await
91+
.unwrap()
92+
.column_into_stream::<u64>("result")
93+
.try_fold(0, |sum, count| async move { Ok(sum + count) })
94+
.await
95+
.unwrap();
5496

55-
let count = graph
56-
.execute_on(
57-
dbname.as_str(),
58-
query("MATCH (n:Node {uuid: $uuid}) RETURN count(n) AS result")
59-
.param("uuid", id.to_string()),
60-
Operation::Read,
61-
)
62-
.await
63-
.unwrap()
64-
.column_into_stream::<u64>("result")
65-
.try_fold(0, |sum, count| async move { Ok(sum + count) })
66-
.await
67-
.unwrap();
97+
assert_eq!(count, 1);
98+
}
6899

69-
assert_eq!(count, 1);
100+
#[cfg(not(feature = "unstable-bolt-protocol-impl-v2"))]
101+
{
102+
let count = graph
103+
.execute_on(
104+
dbname.as_str(),
105+
query("MATCH (n:Node {uuid: $uuid}) RETURN count(n) AS result")
106+
.param("uuid", id.to_string())
107+
)
108+
.await
109+
.unwrap()
110+
.column_into_stream::<u64>("result")
111+
.try_fold(0, |sum, count| async move { Ok(sum + count) })
112+
.await
113+
.unwrap();
114+
115+
assert_eq!(count, 1);
116+
}
70117
}

0 commit comments

Comments
 (0)