use crate::*;
#[test]
fn test_db_error_wraps_into_anyhow() {
fn downstream() -> anyhow::Result<()> {
let _db = Database::open_memory()?; Ok(())
}
downstream().unwrap();
}
#[test]
fn test_db_error_open_variant_has_path() {
let tmp = tempfile::TempDir::new().unwrap();
let file = tmp.path().join("not-a-dir");
std::fs::write(&file, b"x").unwrap();
let bad_path = file.join("db.sqlite");
let err = Database::open(&bad_path, DEFAULT_EMBEDDING_DIM).unwrap_err();
match err {
DbError::Open { path, .. } => assert_eq!(path, bad_path),
DbError::PrepareDir { path, .. } => {
assert_eq!(path, bad_path.parent().unwrap());
}
other => panic!("expected DbError::Open or PrepareDir, got {other:?}"),
}
}