()
| 391 | |
| 392 | #[test] |
| 393 | fn test_kg_neighbors() { |
| 394 | let dir = tempdir().unwrap(); |
| 395 | let pristine = Pristine::open(dir.path().join("db")).unwrap(); |
| 396 | let mut txn = pristine.write_txn().unwrap(); |
| 397 | txn.init_kg().unwrap(); |
| 398 | |
| 399 | txn.upsert_kg_node(&KgNode::new("a", "x", "A", "test")) |
| 400 | .unwrap(); |
| 401 | txn.upsert_kg_node(&KgNode::new("b", "x", "B", "test")) |
| 402 | .unwrap(); |
| 403 | txn.upsert_kg_node(&KgNode::new("c", "x", "C", "test")) |
| 404 | .unwrap(); |
| 405 | txn.upsert_kg_edge(&KgEdge::new("a", "b", "LINK")).unwrap(); |
| 406 | txn.upsert_kg_edge(&KgEdge::new("b", "c", "LINK")).unwrap(); |
| 407 | |
| 408 | // Depth 1 from "a" |
| 409 | let sg = txn.kg_neighbors("a", 1).unwrap(); |
| 410 | assert_eq!(sg.nodes.len(), 2); // a, b |
| 411 | assert_eq!(sg.edges.len(), 1); // a→b |
| 412 | |
| 413 | // Depth 2 from "a" |
| 414 | let sg = txn.kg_neighbors("a", 2).unwrap(); |
| 415 | assert_eq!(sg.nodes.len(), 3); // a, b, c |
| 416 | assert_eq!(sg.edges.len(), 2); // a→b, b→c |
| 417 | |
| 418 | txn.commit().unwrap(); |
| 419 | } |
| 420 | |
| 421 | #[test] |
| 422 | fn test_kg_fts_search() { |
nothing calls this directly
no test coverage detected