mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-27 07:00:05 +01:00
introduce test for meilisearch-http
This commit is contained in:
parent
1b3312871e
commit
83cf683db4
28
meilisearch-http/tests/common.rs
Normal file
28
meilisearch-http/tests/common.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use std::error::Error;
|
||||
|
||||
use tempdir::TempDir;
|
||||
use tide::server::Service;
|
||||
use meilisearch_http::data::Data;
|
||||
use meilisearch_http::option::Opt;
|
||||
use meilisearch_http::routes;
|
||||
|
||||
use http_service_mock::{make_server, TestBackend};
|
||||
|
||||
|
||||
pub fn setup_server() -> Result<TestBackend<Service<Data>>, Box<dyn Error>>{
|
||||
|
||||
let tmp_dir = TempDir::new("meilisearch")?;
|
||||
|
||||
let opt = Opt {
|
||||
db_path: tmp_dir.path().to_str().unwrap().to_string(),
|
||||
http_addr: "127.0.0.1:7700".to_owned(),
|
||||
api_key: None,
|
||||
no_analytics: true,
|
||||
};
|
||||
|
||||
let data = Data::new(opt.clone());
|
||||
let mut app = tide::with_state(data);
|
||||
routes::load_routes(&mut app);
|
||||
let http_server = app.into_http_service();
|
||||
Ok(make_server(http_server)?)
|
||||
}
|
17
meilisearch-http/tests/index_creations.rs
Normal file
17
meilisearch-http/tests/index_creations.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// use async_std::prelude::*;
|
||||
// use async_std::task;
|
||||
// use std::time::Duration;
|
||||
|
||||
// use serde::{Deserialize, Serialize};
|
||||
use http_service::Body;
|
||||
|
||||
mod common;
|
||||
|
||||
#[test]
|
||||
fn create_index() {
|
||||
let mut server = common::setup_server().unwrap();
|
||||
|
||||
let req = http::Request::get("/health").body(Body::empty()).unwrap();
|
||||
let res = server.simulate(req).unwrap();
|
||||
assert_eq!(res.status(), 200);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user