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

Function test_simple_graph_operations

graphlite/tests/fixture_tests.rs:106–168  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

104
105#[test]
106fn test_simple_graph_operations() {
107 let fixture = TestFixture::new().expect("Failed to create test fixture");
108 // Setup fresh graph for this test to avoid interference
109 fixture
110 .setup_graph("test_simple_graph_operations")
111 .expect("Failed to setup graph");
112 // Re-insert simple data since we have a fresh graph
113 fixture
114 .insert_simple_data()
115 .expect("Failed to insert simple data");
116
117 // Test basic counts
118 fixture.assert_first_value(
119 "MATCH (n:TestNode) RETURN count(n) as node_count",
120 "node_count",
121 Value::Number(20.0),
122 );
123
124 fixture.assert_first_value(
125 "MATCH ()-[e:CONNECTS_TO]->() RETURN count(e) as edge_count",
126 "edge_count",
127 Value::Number(9.0), // Creates edges from 1->2, 2->3, ..., 9->10
128 );
129
130 // Test property queries with exact values
131 // From fixture: value = i * 10 (10, 20, 30, ..., 200)
132 fixture.assert_first_value(
133 "MATCH (n:TestNode) WHERE n.value > 100 RETURN count(n) as count",
134 "count",
135 Value::Number(10.0), // Nodes 11-20 have values 110-200
136 );
137
138 // Test aggregate statistics on simple graph
139 let expected_stats = AggregateStats {
140 count: 20.0,
141 sum: 2100.0, // Sum of 10,20,30...200 = 10*(1+2+...+20) = 10*210 = 2100
142 avg: 105.0, // Average = 2100/20 = 105
143 min: 10.0,
144 max: 200.0,
145 };
146
147 let stats = fixture.assert_aggregates(
148 "MATCH (n:TestNode)
149 RETURN count(n.value) as count,
150 sum(n.value) as sum,
151 avg(n.value) as avg,
152 min(n.value) as min,
153 max(n.value) as max",
154 expected_stats,
155 );
156
157 assert_eq!(stats.count, 20.0);
158 assert_eq!(stats.sum, 2100.0);
159 assert_eq!(stats.avg, 105.0);
160 assert_eq!(stats.min, 10.0); // Minimum value is 10 (node 1)
161 assert_eq!(stats.max, 200.0); // Maximum value is 200 (node 20)
162
163 // Test path traversal (simplified - path assignment may not be supported)

Callers

nothing calls this directly

Calls 5

setup_graphMethod · 0.80
insert_simple_dataMethod · 0.80
assert_first_valueMethod · 0.80
assert_aggregatesMethod · 0.80
assert_query_succeedsMethod · 0.45

Tested by

no test coverage detected