Skip to content

Commit acdd051

Browse files
committed
Change examples/tests to use query macro where possible
1 parent 4b53bd0 commit acdd051

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

lib/tests/missing_properties.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ async fn missing_properties() {
1010

1111
let a_val = None::<String>;
1212
let mut result = graph
13-
.execute(query("CREATE (ts:TestStruct {a: $a}) RETURN ts").param("a", a_val))
13+
.execute(query!(
14+
"CREATE (ts:TestStruct {{a: {a}}}) RETURN ts",
15+
a = a_val
16+
))
1417
.await
1518
.unwrap();
1619
let row = result.next().await.unwrap().unwrap();

lib/tests/txn_change_db.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use futures::TryStreamExt;
2-
use neo4rs::*;
2+
use neo4rs::query;
33
use serde::Deserialize;
44

55
mod container;
@@ -19,7 +19,7 @@ async fn txn_changes_db() {
1919
return;
2020
}
2121

22-
std::panic::panic_any(e);
22+
std::panic::panic_any(e.to_string());
2323
}
2424
};
2525
let graph = neo4j.graph();
@@ -46,18 +46,13 @@ async fn txn_changes_db() {
4646

4747
let mut txn = graph.start_txn().await.unwrap();
4848
let mut databases = txn
49-
.execute(
50-
query(&format!(
51-
concat!(
52-
"SHOW TRANSACTIONS YIELD * WHERE username = $username AND currentQuery ",
53-
"STARTS WITH $query AND toLower({status_field}) = $status RETURN database"
54-
),
55-
status_field = status_field
56-
))
57-
.param("username", "neo4j")
58-
.param("query", "SHOW TRANSACTIONS YIELD ")
59-
.param("status", "running"),
60-
)
49+
.execute(dbg!(query!(
50+
"SHOW TRANSACTIONS YIELD * WHERE username = {username} AND currentQuery
51+
STARTS WITH {query} AND toLower({status_field}) = {status} RETURN database",
52+
username = "neo4j",
53+
query = "SHOW TRANSACTIONS YIELD ",
54+
status = "running",
55+
)))
6156
.await
6257
.unwrap();
6358

lib/tests/use_default_db.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,21 @@ async fn use_default_db() {
5454

5555
let id = uuid::Uuid::new_v4();
5656
graph
57-
.run(query("CREATE (:Node { uuid: $uuid })").param("uuid", id.to_string()))
57+
.run(query!(
58+
"CREATE (:Node {{ uuid: {uuid} }})",
59+
uuid = id.to_string()
60+
))
5861
.await
5962
.unwrap();
6063

6164
#[cfg(feature = "unstable-bolt-protocol-impl-v2")]
6265
let query_stream = graph
6366
.execute_on(
6467
dbname.as_str(),
65-
query("MATCH (n:Node {uuid: $uuid}) RETURN count(n) AS result")
66-
.param("uuid", id.to_string()),
68+
query!(
69+
"MATCH (n:Node {{uuid: {uuid}}}) RETURN count(n) AS result",
70+
uuid = id.to_string()
71+
),
6772
Operation::Read,
6873
)
6974
.await;
@@ -72,8 +77,10 @@ async fn use_default_db() {
7277
let query_stream = graph
7378
.execute_on(
7479
dbname.as_str(),
75-
query("MATCH (n:Node {uuid: $uuid}) RETURN count(n) AS result")
76-
.param("uuid", id.to_string()),
80+
query!(
81+
"MATCH (n:Node {{uuid: {uuid}}}) RETURN count(n) AS result",
82+
uuid = id.to_string()
83+
),
7784
)
7885
.await;
7986

0 commit comments

Comments
 (0)