add test for authorize_typos in update

This commit is contained in:
ad hoc 2022-03-31 14:12:00 +02:00
parent 6ef3bb9d83
commit 3e34981d9b
No known key found for this signature in database
GPG Key ID: 4F00A782990CC643

View File

@ -518,6 +518,7 @@ mod tests {
use super::*; use super::*;
use crate::error::Error; use crate::error::Error;
use crate::index::tests::TempIndex;
use crate::update::IndexDocuments; use crate::update::IndexDocuments;
use crate::{Criterion, Filter, SearchResult}; use crate::{Criterion, Filter, SearchResult};
@ -1218,4 +1219,18 @@ mod tests {
let line = std::str::from_utf8(content.get(fid).unwrap()).unwrap(); let line = std::str::from_utf8(content.get(fid).unwrap()).unwrap();
assert_eq!(line, r#""Star Wars""#); assert_eq!(line, r#""Star Wars""#);
} }
#[test]
fn test_disable_typo() {
let index = TempIndex::new();
let mut txn = index.write_txn().unwrap();
let config = IndexerConfig::default();
assert!(index.authorize_typos(&txn).unwrap());
let mut builder = Settings::new(&mut txn, &index, &config);
builder.set_autorize_typos(false);
builder.execute(|_| ()).unwrap();
assert!(!index.authorize_typos(&txn).unwrap());
}
} }