mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
add tests
This commit is contained in:
parent
75464a1baa
commit
9c4660d3d6
5 changed files with 242 additions and 9 deletions
|
@ -478,13 +478,44 @@ impl Index {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
pub(crate) mod tests {
|
||||
use std::ops::Deref;
|
||||
|
||||
use heed::EnvOpenOptions;
|
||||
use maplit::hashmap;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use crate::Index;
|
||||
use crate::update::{IndexDocuments, UpdateFormat};
|
||||
|
||||
pub(crate) struct TempIndex {
|
||||
inner: Index,
|
||||
_tempdir: TempDir,
|
||||
}
|
||||
|
||||
impl Deref for TempIndex {
|
||||
type Target = Index;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl TempIndex {
|
||||
/// Creates a temporary index, with a default `4096 * 100` size. This should be enough for
|
||||
/// most tests.
|
||||
pub fn new() -> Self {
|
||||
let mut options = EnvOpenOptions::new();
|
||||
options.map_size(100 * 4096);
|
||||
let _tempdir = TempDir::new_in(".").unwrap();
|
||||
let inner = Index::new(options, _tempdir.path()).unwrap();
|
||||
Self {
|
||||
inner,
|
||||
_tempdir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn initial_fields_distribution() {
|
||||
let path = tempfile::tempdir().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue