use std::path::PathBuf;
use crate::index;
use crate::store::Store;
use crate::tests::support::top;
fn indexed_src() -> Store {
let src = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src");
let mut store = Store::open_in_memory().unwrap();
index::index_path(&mut store, &src).unwrap();
store
}
#[test]
fn obvious_queries_land_their_definition_first() {
let store = indexed_src();
let symbol = top(&store, "Symbol");
assert_eq!(symbol.name, "Symbol");
assert_eq!(symbol.kind, "struct");
assert_eq!(top(&store, "LanguagePlugin").kind, "trait");
assert_eq!(top(&store, "index_budgeted").name, "index_budgeted");
let fs = top(&store, "FileSymbols");
assert_eq!(fs.name, "FileSymbols");
assert_eq!(fs.kind, "struct");
}
#[test]
fn fuzzy_abbreviations_resolve_to_their_definition() {
let store = indexed_src();
assert_eq!(top(&store, "idxbudg").name, "index_budgeted"); assert_eq!(top(&store, "filesym").name, "FileSymbols"); assert_eq!(top(&store, "langplug").name, "LanguagePlugin"); }