()
| 246 | |
| 247 | #[test] |
| 248 | fn test_delete_operations() { |
| 249 | let fixture = TestFixture::empty().expect("Failed to create test fixture"); |
| 250 | |
| 251 | // Create schema and graph for this test (ISO GQL compliant) |
| 252 | fixture |
| 253 | .query(&format!( |
| 254 | "CREATE SCHEMA IF NOT EXISTS /{}", |
| 255 | fixture.schema_name() |
| 256 | )) |
| 257 | .unwrap(); |
| 258 | fixture |
| 259 | .query(&format!( |
| 260 | "CREATE GRAPH /{}/delete_test_graph", |
| 261 | fixture.schema_name() |
| 262 | )) |
| 263 | .unwrap(); |
| 264 | fixture |
| 265 | .query(&format!( |
| 266 | "SESSION SET GRAPH /{}/delete_test_graph", |
| 267 | fixture.schema_name() |
| 268 | )) |
| 269 | .unwrap(); |
| 270 | |
| 271 | // Insert test data for deletion |
| 272 | fixture.assert_query_succeeds( |
| 273 | "INSERT (delete_me:DeleteTest {name: 'ToDelete'}), |
| 274 | (keep_me:DeleteTest {name: 'ToKeep'}), |
| 275 | (other:Other {name: 'Other'})", |
| 276 | ); |
| 277 | |
| 278 | fixture.assert_query_succeeds( |
| 279 | "MATCH (d:DeleteTest {name: 'ToDelete'}), (o:Other) |
| 280 | INSERT (d)-[:RELATED_TO]->(o)", |
| 281 | ); |
| 282 | |
| 283 | // Test simple node deletion with relationships (requires DETACH) |
| 284 | fixture.assert_query_succeeds( |
| 285 | "MATCH (d:DeleteTest {name: 'ToDelete'}) |
| 286 | DETACH DELETE d", |
| 287 | ); |
| 288 | |
| 289 | // Verify deletion - use query instead of assert_first_value to handle empty results |
| 290 | let result = fixture |
| 291 | .query( |
| 292 | "MATCH (d:DeleteTest {name: 'ToDelete'}) |
| 293 | RETURN count(d) as count", |
| 294 | ) |
| 295 | .unwrap(); |
| 296 | |
| 297 | // COUNT should return 1 row even with 0 count |
| 298 | assert_eq!( |
| 299 | result.rows.len(), |
| 300 | 1, |
| 301 | "COUNT should always return exactly 1 row" |
| 302 | ); |
| 303 | let count = result.rows[0].values.get("count").unwrap(); |
| 304 | assert_eq!( |
| 305 | count, |
nothing calls this directly
no test coverage detected