Added unit test.

This commit is contained in:
Paul Masurel
2019-12-10 22:49:32 +09:00
parent 79474288d0
commit afa5715e56

View File

@@ -770,8 +770,8 @@ mod tests {
use crate::error::*;
use crate::indexer::NoMergePolicy;
use crate::query::TermQuery;
use crate::schema::{self, IndexRecordOption};
use crate::Index;
use crate::schema::{self, IndexRecordOption, STRING};
use crate::{Index, Document};
use crate::ReloadPolicy;
use crate::Term;
@@ -1195,4 +1195,17 @@ mod tests {
assert!(clear_again.is_ok());
assert!(commit_again.is_ok());
}
#[test]
fn test_index_doc_missing_field() {
let mut schema_builder = schema::Schema::builder();
let idfield = schema_builder.add_text_field("id", STRING);
let optfield = schema_builder.add_text_field("optfield", STRING);
let index = Index::create_in_ram(schema_builder.build());
let mut index_writer = index.writer_with_num_threads(1, 3_000_000).unwrap();
let doc = Document::default();
index_writer.add_document(doc!(idfield=>"myid"));
let commit = index_writer.commit();
assert!(commit.is_ok());
}
}