MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / test_count_with_id_argument

Function test_count_with_id_argument

graphlite/tests/function_tests.rs:221–261  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

219
220#[test]
221fn test_count_with_id_argument() {
222 let fixture = TestFixture::new().expect("Failed to create test fixture");
223 // Setup fresh graph for this test to avoid interference
224 fixture
225 .setup_graph("test_count_with_id_argument")
226 .expect("Failed to setup graph");
227 // Re-insert fraud data since we have a fresh graph
228 fixture
229 .insert_fraud_data()
230 .expect("Failed to insert fraud data");
231
232 // Test COUNT(account) vs COUNT(account.id)
233 let result1 = fixture.assert_query_succeeds(
234 "MATCH (account:Account) WHERE account.balance > 2000 RETURN COUNT(account) as count_node",
235 );
236
237 let result2 = fixture.assert_query_succeeds(
238 "MATCH (account:Account) WHERE account.balance > 2000 RETURN COUNT(account.id) as count_id",
239 );
240
241 // Both should return the same count since id is never null
242 if let (Some(row1), Some(row2)) = (result1.rows.first(), result2.rows.first()) {
243 let count_node = row1
244 .values
245 .get("count_node")
246 .expect("Should have count_node");
247 let count_id = row2.values.get("count_id").expect("Should have count_id");
248
249 if let (Value::Number(count1), Value::Number(count2)) = (count_node, count_id) {
250 assert_eq!(
251 count1, count2,
252 "COUNT(account) and COUNT(account.id) should be equal"
253 );
254 assert!(*count1 >= 0.0, "Count should be non-negative");
255 } else {
256 panic!("Both COUNT operations should return Numbers");
257 }
258 } else {
259 panic!("Both queries should return at least one row");
260 }
261}
262
263#[test]
264fn test_sum_end_to_end_with_where_clause() {

Callers

nothing calls this directly

Calls 5

setup_graphMethod · 0.80
insert_fraud_dataMethod · 0.80
assert_query_succeedsMethod · 0.45
firstMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected