()
| 572 | |
| 573 | #[test] |
| 574 | fn test_kg_fts_search() { |
| 575 | let dir = tempdir().unwrap(); |
| 576 | let pristine = Pristine::open(dir.path().join("db")).unwrap(); |
| 577 | let mut txn = pristine.write_txn().unwrap(); |
| 578 | txn.init_kg().unwrap(); |
| 579 | |
| 580 | txn.upsert_kg_node( |
| 581 | &KgNode::new("change:abc", "change", "abc123", "graph") |
| 582 | .with_summary("Fix authentication bug"), |
| 583 | ) |
| 584 | .unwrap(); |
| 585 | txn.upsert_kg_node( |
| 586 | &KgNode::new("change:def", "change", "def456", "graph").with_summary("Add logging"), |
| 587 | ) |
| 588 | .unwrap(); |
| 589 | |
| 590 | // Search for "authentication" |
| 591 | let results = txn.kg_fts_search("authentication", 10).unwrap(); |
| 592 | assert_eq!(results.len(), 1); |
| 593 | assert_eq!(results[0].id, "change:abc"); |
| 594 | |
| 595 | // Search for "fix" matches abc's summary |
| 596 | let results = txn.kg_fts_search("fix", 10).unwrap(); |
| 597 | assert_eq!(results.len(), 1); |
| 598 | assert_eq!(results[0].id, "change:abc"); |
| 599 | |
| 600 | // Search for "logging" matches def |
| 601 | let results = txn.kg_fts_search("logging", 10).unwrap(); |
| 602 | assert_eq!(results.len(), 1); |
| 603 | assert_eq!(results[0].id, "change:def"); |
| 604 | |
| 605 | txn.commit().unwrap(); |
| 606 | } |
| 607 | |
| 608 | #[test] |
| 609 | fn test_kg_upsert_replaces_fts_tokens() { |
nothing calls this directly
no test coverage detected