mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
delete index test
This commit is contained in:
parent
20dd259f23
commit
0e416b4bcd
@ -470,8 +470,12 @@ mod real {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use crate::index::IndexStats;
|
||||||
|
|
||||||
|
use super::{index_store::MockIndexStore, meta_store::MockIndexMetaStore, *};
|
||||||
|
|
||||||
|
use futures::future::ok;
|
||||||
|
use milli::FieldDistribution;
|
||||||
use nelson::Mocker;
|
use nelson::Mocker;
|
||||||
|
|
||||||
pub enum MockIndexResolver<U, I> {
|
pub enum MockIndexResolver<U, I> {
|
||||||
@ -577,6 +581,79 @@ mod test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_remove_unknown_index() {
|
||||||
|
let mut meta_store = MockIndexMetaStore::new();
|
||||||
|
meta_store
|
||||||
|
.expect_delete()
|
||||||
|
.once()
|
||||||
|
.returning(|_| Box::pin(ok(None)));
|
||||||
|
|
||||||
|
let index_store = MockIndexStore::new();
|
||||||
|
|
||||||
|
let mocker = Mocker::default();
|
||||||
|
let file_store = UpdateFileStore::mock(mocker);
|
||||||
|
|
||||||
|
let index_resolver = IndexResolver::new(meta_store, index_store, file_store);
|
||||||
|
|
||||||
|
let mut task = Task {
|
||||||
|
id: 1,
|
||||||
|
content: TaskContent::IndexDeletion {
|
||||||
|
index_uid: IndexUid::new_unchecked("test"),
|
||||||
|
},
|
||||||
|
events: Vec::new(),
|
||||||
|
};
|
||||||
|
|
||||||
|
index_resolver.process_task(&mut task).await;
|
||||||
|
|
||||||
|
assert!(matches!(task.events[0], TaskEvent::Failed { .. }));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_remove_index() {
|
||||||
|
let mut meta_store = MockIndexMetaStore::new();
|
||||||
|
meta_store.expect_delete().once().returning(|_| {
|
||||||
|
Box::pin(ok(Some(IndexMeta {
|
||||||
|
uuid: Uuid::new_v4(),
|
||||||
|
creation_task_id: 1,
|
||||||
|
})))
|
||||||
|
});
|
||||||
|
|
||||||
|
let mut index_store = MockIndexStore::new();
|
||||||
|
index_store.expect_delete().once().returning(|_| {
|
||||||
|
let mocker = Mocker::default();
|
||||||
|
mocker.when::<(), ()>("close").then(|_| ());
|
||||||
|
mocker
|
||||||
|
.when::<(), IndexResult<IndexStats>>("stats")
|
||||||
|
.then(|_| {
|
||||||
|
Ok(IndexStats {
|
||||||
|
size: 10,
|
||||||
|
number_of_documents: 10,
|
||||||
|
is_indexing: None,
|
||||||
|
field_distribution: FieldDistribution::default(),
|
||||||
|
})
|
||||||
|
});
|
||||||
|
Box::pin(ok(Some(Index::mock(mocker))))
|
||||||
|
});
|
||||||
|
|
||||||
|
let mocker = Mocker::default();
|
||||||
|
let file_store = UpdateFileStore::mock(mocker);
|
||||||
|
|
||||||
|
let index_resolver = IndexResolver::new(meta_store, index_store, file_store);
|
||||||
|
|
||||||
|
let mut task = Task {
|
||||||
|
id: 1,
|
||||||
|
content: TaskContent::IndexDeletion {
|
||||||
|
index_uid: IndexUid::new_unchecked("test"),
|
||||||
|
},
|
||||||
|
events: Vec::new(),
|
||||||
|
};
|
||||||
|
|
||||||
|
index_resolver.process_task(&mut task).await;
|
||||||
|
|
||||||
|
assert!(matches!(task.events[0], TaskEvent::Succeeded { .. }));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: ignoring this test, it has become too complex to maintain, and rather implement
|
// TODO: ignoring this test, it has become too complex to maintain, and rather implement
|
||||||
// handler logic test.
|
// handler logic test.
|
||||||
// proptest! {
|
// proptest! {
|
||||||
|
Loading…
Reference in New Issue
Block a user