mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 00:31:02 +00:00
integration test snapshot
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
mod index;
|
||||
mod server;
|
||||
mod service;
|
||||
pub mod index;
|
||||
pub mod server;
|
||||
pub mod service;
|
||||
|
||||
pub use index::{GetAllDocumentsOptions, GetDocumentOptions};
|
||||
pub use server::Server;
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::path::Path;
|
||||
|
||||
use actix_web::http::StatusCode;
|
||||
use byte_unit::{Byte, ByteUnit};
|
||||
use serde_json::Value;
|
||||
@ -12,50 +14,27 @@ use super::service::Service;
|
||||
|
||||
pub struct Server {
|
||||
pub service: Service,
|
||||
// hod ownership to the tempdir while we use the server instance.
|
||||
_dir: tempdir::TempDir,
|
||||
// hold ownership to the tempdir while we use the server instance.
|
||||
_dir: Option<tempdir::TempDir>,
|
||||
}
|
||||
|
||||
impl Server {
|
||||
pub async fn new() -> Self {
|
||||
let dir = TempDir::new("meilisearch").unwrap();
|
||||
|
||||
let opt = Opt {
|
||||
db_path: dir.path().join("db"),
|
||||
dumps_dir: dir.path().join("dump"),
|
||||
dump_batch_size: 16,
|
||||
http_addr: "127.0.0.1:7700".to_owned(),
|
||||
master_key: None,
|
||||
env: "development".to_owned(),
|
||||
no_analytics: true,
|
||||
max_mdb_size: Byte::from_unit(4.0, ByteUnit::GiB).unwrap(),
|
||||
max_udb_size: Byte::from_unit(4.0, ByteUnit::GiB).unwrap(),
|
||||
http_payload_size_limit: Byte::from_unit(10.0, ByteUnit::MiB).unwrap(),
|
||||
ssl_cert_path: None,
|
||||
ssl_key_path: None,
|
||||
ssl_auth_path: None,
|
||||
ssl_ocsp_path: None,
|
||||
ssl_require_auth: false,
|
||||
ssl_resumption: false,
|
||||
ssl_tickets: false,
|
||||
import_snapshot: None,
|
||||
ignore_missing_snapshot: false,
|
||||
ignore_snapshot_if_db_exists: false,
|
||||
snapshot_dir: ".".into(),
|
||||
schedule_snapshot: false,
|
||||
snapshot_interval_sec: 0,
|
||||
import_dump: None,
|
||||
indexer_options: IndexerOpts::default(),
|
||||
#[cfg(all(not(debug_assertions), feature = "sentry"))]
|
||||
sentry_dsn: String::from(""),
|
||||
#[cfg(all(not(debug_assertions), feature = "sentry"))]
|
||||
no_sentry: true,
|
||||
};
|
||||
let opt = default_settings(dir.path());
|
||||
|
||||
let data = Data::new(opt).unwrap();
|
||||
let service = Service(data);
|
||||
|
||||
Server { service, _dir: dir }
|
||||
Server { service, _dir: Some(dir) }
|
||||
}
|
||||
|
||||
pub async fn new_with_options(opt: Opt) -> Self {
|
||||
let data = Data::new(opt).unwrap();
|
||||
let service = Service(data);
|
||||
|
||||
Server { service, _dir: None }
|
||||
}
|
||||
|
||||
/// Returns a view to an index. There is no guarantee that the index exists.
|
||||
@ -74,3 +53,37 @@ impl Server {
|
||||
self.service.get("/version").await
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_settings(dir: impl AsRef<Path>) -> Opt {
|
||||
Opt {
|
||||
db_path: dir.as_ref().join("db"),
|
||||
dumps_dir: dir.as_ref().join("dump"),
|
||||
dump_batch_size: 16,
|
||||
http_addr: "127.0.0.1:7700".to_owned(),
|
||||
master_key: None,
|
||||
env: "development".to_owned(),
|
||||
no_analytics: true,
|
||||
max_mdb_size: Byte::from_unit(4.0, ByteUnit::GiB).unwrap(),
|
||||
max_udb_size: Byte::from_unit(4.0, ByteUnit::GiB).unwrap(),
|
||||
http_payload_size_limit: Byte::from_unit(10.0, ByteUnit::MiB).unwrap(),
|
||||
ssl_cert_path: None,
|
||||
ssl_key_path: None,
|
||||
ssl_auth_path: None,
|
||||
ssl_ocsp_path: None,
|
||||
ssl_require_auth: false,
|
||||
ssl_resumption: false,
|
||||
ssl_tickets: false,
|
||||
import_snapshot: None,
|
||||
ignore_missing_snapshot: false,
|
||||
ignore_snapshot_if_db_exists: false,
|
||||
snapshot_dir: ".".into(),
|
||||
schedule_snapshot: false,
|
||||
snapshot_interval_sec: 0,
|
||||
import_dump: None,
|
||||
indexer_options: IndexerOpts::default(),
|
||||
#[cfg(all(not(debug_assertions), feature = "sentry"))]
|
||||
sentry_dsn: String::from(""),
|
||||
#[cfg(all(not(debug_assertions), feature = "sentry"))]
|
||||
no_sentry: true,
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,9 @@ mod documents;
|
||||
mod index;
|
||||
mod search;
|
||||
mod settings;
|
||||
mod updates;
|
||||
mod snapshot;
|
||||
mod stats;
|
||||
mod updates;
|
||||
|
||||
// Tests are isolated by features in different modules to allow better readability, test
|
||||
// targetability, and improved incremental compilation times.
|
||||
|
Reference in New Issue
Block a user