mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 13:24:27 +01:00
add tests for list index and create index.
This commit is contained in:
parent
f988306691
commit
8d462afb79
@ -129,3 +129,17 @@ impl IndexController for LocalIndexController {
|
|||||||
Ok(output_meta)
|
Ok(output_meta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use tempfile::tempdir;
|
||||||
|
use crate::make_index_controller_tests;
|
||||||
|
|
||||||
|
make_index_controller_tests!({
|
||||||
|
let options = IndexerOpts::default();
|
||||||
|
let path = tempdir().unwrap();
|
||||||
|
let size = 4096 * 100;
|
||||||
|
LocalIndexController::new(path, options, size, size).unwrap()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -155,3 +155,30 @@ pub trait IndexController {
|
|||||||
|
|
||||||
fn list_indexes(&self) -> anyhow::Result<Vec<IndexMetadata>>;
|
fn list_indexes(&self) -> anyhow::Result<Vec<IndexMetadata>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[macro_use]
|
||||||
|
pub(crate) mod test {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! make_index_controller_tests {
|
||||||
|
($controller_buider:block) => {
|
||||||
|
#[test]
|
||||||
|
fn test_create_and_list_indexes() {
|
||||||
|
crate::index_controller::test::create_and_list_indexes($controller_buider);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn create_and_list_indexes<S: IndexController>(controller: S) {
|
||||||
|
controller.create_index("test_index").unwrap();
|
||||||
|
controller.create_index("test_index2").unwrap();
|
||||||
|
|
||||||
|
let indexes = controller.list_indexes().unwrap();
|
||||||
|
assert_eq!(indexes.len(), 2);
|
||||||
|
assert_eq!(indexes[0].name, "test_index");
|
||||||
|
assert_eq!(indexes[1].name, "test_index2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user