From ef14b130937655fd9675128fb09d34948daab884 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 28 Nov 2024 14:09:32 -0500 Subject: [PATCH] test: Disable some tests requiring running neo4j instance --- node/src/neo4j_utils.rs | 227 ++++++++++++++++++++-------------------- 1 file changed, 114 insertions(+), 113 deletions(-) diff --git a/node/src/neo4j_utils.rs b/node/src/neo4j_utils.rs index a5dc438..96d6cb8 100644 --- a/node/src/neo4j_utils.rs +++ b/node/src/neo4j_utils.rs @@ -230,154 +230,155 @@ pub fn serde_value_to_bolt(value: serde_json::Value) -> BoltType { } } -#[cfg(test)] -mod tests { - use super::*; +// TODO: Re-enale these tests with `testcontainers` to run against a real Neo4j instance. +// #[cfg(test)] +// mod tests { +// use super::*; - #[tokio::test] - async fn test_find_one_node() { - let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") - .await - .unwrap(); +// #[tokio::test] +// async fn test_find_one_node() { +// let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") +// .await +// .unwrap(); - let query = neo4rs::query("MATCH (n) RETURN n LIMIT 1"); +// let query = neo4rs::query("MATCH (n) RETURN n LIMIT 1"); - let node: Option = graph.find_one(query).await.unwrap(); - println!("{:?}", node); - } +// let node: Option = graph.find_one(query).await.unwrap(); +// println!("{:?}", node); +// } - #[tokio::test] - async fn test_find_one_relation() { - let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") - .await - .unwrap(); +// #[tokio::test] +// async fn test_find_one_relation() { +// let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") +// .await +// .unwrap(); - let query = neo4rs::query("MATCH () -[r]-> () RETURN r LIMIT 1"); +// let query = neo4rs::query("MATCH () -[r]-> () RETURN r LIMIT 1"); - let node: Option = graph.find_one(query).await.unwrap(); - println!("{:?}", node); - } +// let node: Option = graph.find_one(query).await.unwrap(); +// println!("{:?}", node); +// } - #[tokio::test] - async fn test_find_all_nodes() { - let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") - .await - .unwrap(); +// #[tokio::test] +// async fn test_find_all_nodes() { +// let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") +// .await +// .unwrap(); - let query = neo4rs::query("MATCH (n:`d7ab40920ab5441e88c35c27952de773`) RETURN n LIMIT 4"); +// let query = neo4rs::query("MATCH (n:`d7ab40920ab5441e88c35c27952de773`) RETURN n LIMIT 4"); - let nodes: Vec = graph.find_all(query).await.unwrap(); - println!("{:?}", nodes); - } +// let nodes: Vec = graph.find_all(query).await.unwrap(); +// println!("{:?}", nodes); +// } - #[tokio::test] - async fn test_find_all_relations() { - let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") - .await - .unwrap(); +// #[tokio::test] +// async fn test_find_all_relations() { +// let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") +// .await +// .unwrap(); - let query = - neo4rs::query("MATCH () -[r:`01412f8381894ab1836565c7fd358cc1`]-> () RETURN r LIMIT 4"); +// let query = +// neo4rs::query("MATCH () -[r:`01412f8381894ab1836565c7fd358cc1`]-> () RETURN r LIMIT 4"); - let nodes: Vec = graph.find_all(query).await.unwrap(); - println!("{:?}", nodes); - } +// let nodes: Vec = graph.find_all(query).await.unwrap(); +// println!("{:?}", nodes); +// } - #[tokio::test] - async fn test_find_all_relations_and_nodes() { - let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") - .await - .unwrap(); +// #[tokio::test] +// async fn test_find_all_relations_and_nodes() { +// let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") +// .await +// .unwrap(); - let query = neo4rs::query("MATCH () -[r:`577bd9fbb29e4e2bb5f8f48aedbd26ac`]-> () MATCH (n:`3d0b19e0313843479687a351223efcc3`) RETURN n, r LIMIT 8"); +// let query = neo4rs::query("MATCH () -[r:`577bd9fbb29e4e2bb5f8f48aedbd26ac`]-> () MATCH (n:`3d0b19e0313843479687a351223efcc3`) RETURN n, r LIMIT 8"); - let nodes: Vec = graph.find_all(query).await.unwrap(); - println!("{}", serde_json::to_string_pretty(&nodes).unwrap()); - } +// let nodes: Vec = graph.find_all(query).await.unwrap(); +// println!("{}", serde_json::to_string_pretty(&nodes).unwrap()); +// } - #[tokio::test] - async fn test_find_one_node_txn() { - let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") - .await - .unwrap(); +// #[tokio::test] +// async fn test_find_one_node_txn() { +// let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") +// .await +// .unwrap(); - let mut txn = graph.start_txn().await.unwrap(); +// let mut txn = graph.start_txn().await.unwrap(); - txn.run(neo4rs::query("CREATE (n:TestNode {name: \"potato\"})")) - .await - .unwrap(); +// txn.run(neo4rs::query("CREATE (n:TestNode {name: \"potato\"})")) +// .await +// .unwrap(); - let query = neo4rs::query("MATCH (n:TestNode) RETURN n LIMIT 1"); +// let query = neo4rs::query("MATCH (n:TestNode) RETURN n LIMIT 1"); - let node: Option = txn.find_one(query).await.unwrap(); +// let node: Option = txn.find_one(query).await.unwrap(); - txn.rollback().await.unwrap(); +// txn.rollback().await.unwrap(); - println!("{:?}", node); - } +// println!("{:?}", node); +// } - #[tokio::test] - async fn test_insert_one_txn() { - let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") - .await - .unwrap(); +// #[tokio::test] +// async fn test_insert_one_txn() { +// let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") +// .await +// .unwrap(); - let mut txn = graph.start_txn().await.unwrap(); +// let mut txn = graph.start_txn().await.unwrap(); - #[derive(Deserialize, Debug, Serialize)] - #[serde(tag = "$type")] - struct Foo { - name: String, - } +// #[derive(Deserialize, Debug, Serialize)] +// #[serde(tag = "$type")] +// struct Foo { +// name: String, +// } - let node = Foo { - name: "potato".to_string(), - }; +// let node = Foo { +// name: "potato".to_string(), +// }; - txn.insert_one(node).await.unwrap(); +// txn.insert_one(node).await.unwrap(); - let node: Option = txn - .find_one(neo4rs::query("MATCH (n:Foo) RETURN n LIMIT 1")) - .await - .unwrap(); +// let node: Option = txn +// .find_one(neo4rs::query("MATCH (n:Foo) RETURN n LIMIT 1")) +// .await +// .unwrap(); - txn.rollback().await.unwrap(); +// txn.rollback().await.unwrap(); - println!("{:?}", node); - } +// println!("{:?}", node); +// } - #[tokio::test] - async fn test_insert_many_txn() { - let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") - .await - .unwrap(); +// #[tokio::test] +// async fn test_insert_many_txn() { +// let graph = neo4rs::Graph::new("neo4j://localhost:7687", "", "") +// .await +// .unwrap(); - let mut txn = graph.start_txn().await.unwrap(); +// let mut txn = graph.start_txn().await.unwrap(); - #[derive(Deserialize, Debug, Serialize)] - #[serde(tag = "$type")] - struct Foo { - name: String, - } +// #[derive(Deserialize, Debug, Serialize)] +// #[serde(tag = "$type")] +// struct Foo { +// name: String, +// } - let nodes = vec![ - Foo { - name: "potato".to_string(), - }, - Foo { - name: "pizza".to_string(), - }, - ]; +// let nodes = vec![ +// Foo { +// name: "potato".to_string(), +// }, +// Foo { +// name: "pizza".to_string(), +// }, +// ]; - txn.insert_many(nodes).await.unwrap(); +// txn.insert_many(nodes).await.unwrap(); - let node: Vec = txn - .find_all(neo4rs::query("MATCH (n:Foo) RETURN n")) - .await - .unwrap(); +// let node: Vec = txn +// .find_all(neo4rs::query("MATCH (n:Foo) RETURN n")) +// .await +// .unwrap(); - txn.rollback().await.unwrap(); +// txn.rollback().await.unwrap(); - println!("{:?}", node); - } -} +// println!("{:?}", node); +// } +// }