Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
barakb committed Dec 10, 2024
1 parent 8bd6cf5 commit 95ea43e
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/client/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ impl FalkorSyncClient {
})
}


/// Get the max number of connections in the client's connection pool
pub fn connection_pool_size(&self) -> u8 {
self.inner.connection_pool_size
Expand Down Expand Up @@ -294,6 +293,40 @@ mod tests {
let graphs = res.unwrap();
assert!(graphs.contains(&"imdb".to_string()));
}

#[test]
fn test_read_only_query() {
let client = create_test_client();
let mut graph = client.select_graph("test_read_only_query");
graph
.query("CREATE (n:Person {name: 'John Doe', age: 30})")
.execute()
.expect("Could not create John");
graph
.ro_query("MATCH (n:Person {name: 'John Doe', age: 30}) RETURN n")
.execute()
.expect("Could not read John");
let result = graph
.ro_query("CREATE (n:Person {name: 'John Doe', age: 30})")
.execute();

assert!(
result.is_err(),
"Expected an error for write operation in read-only query"
);

if let Err(e) = result {
assert!(
e.to_string()
.contains("is to be executed only on read-only queries"),
"Unexpected error message: {}",
e
);
}

graph.delete().unwrap();
}

#[test]
fn test_read_vec32() {
let client = create_test_client();
Expand Down

0 comments on commit 95ea43e

Please sign in to comment.