mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-23 21:20:24 +01:00
add tests
This commit is contained in:
parent
71e3b5bc11
commit
f2b7aea16c
@ -7,6 +7,7 @@ use actix_web::{http::StatusCode, test};
|
||||
use meilisearch_core::DatabaseOptions;
|
||||
use meilisearch_http::data::Data;
|
||||
use meilisearch_http::option::Opt;
|
||||
use meilisearch_http::helpers::NormalizeSlashes;
|
||||
use tempdir::TempDir;
|
||||
use tokio::time::delay_for;
|
||||
|
||||
@ -126,7 +127,7 @@ impl Server {
|
||||
pub async fn get_request(&mut self, url: &str) -> (Value, StatusCode) {
|
||||
eprintln!("get_request: {}", url);
|
||||
|
||||
let mut app = test::init_service(meilisearch_http::create_app(&self.data)).await;
|
||||
let mut app = test::init_service(meilisearch_http::create_app(&self.data).wrap(NormalizeSlashes)).await;
|
||||
|
||||
let req = test::TestRequest::get().uri(url).to_request();
|
||||
let res = test::call_service(&mut app, req).await;
|
||||
@ -140,7 +141,7 @@ impl Server {
|
||||
pub async fn post_request(&mut self, url: &str, body: Value) -> (Value, StatusCode) {
|
||||
eprintln!("post_request: {}", url);
|
||||
|
||||
let mut app = test::init_service(meilisearch_http::create_app(&self.data)).await;
|
||||
let mut app = test::init_service(meilisearch_http::create_app(&self.data).wrap(NormalizeSlashes)).await;
|
||||
|
||||
let req = test::TestRequest::post()
|
||||
.uri(url)
|
||||
@ -169,7 +170,7 @@ impl Server {
|
||||
pub async fn put_request(&mut self, url: &str, body: Value) -> (Value, StatusCode) {
|
||||
eprintln!("put_request: {}", url);
|
||||
|
||||
let mut app = test::init_service(meilisearch_http::create_app(&self.data)).await;
|
||||
let mut app = test::init_service(meilisearch_http::create_app(&self.data).wrap(NormalizeSlashes)).await;
|
||||
|
||||
let req = test::TestRequest::put()
|
||||
.uri(url)
|
||||
@ -197,7 +198,7 @@ impl Server {
|
||||
pub async fn delete_request(&mut self, url: &str) -> (Value, StatusCode) {
|
||||
eprintln!("delete_request: {}", url);
|
||||
|
||||
let mut app = test::init_service(meilisearch_http::create_app(&self.data)).await;
|
||||
let mut app = test::init_service(meilisearch_http::create_app(&self.data).wrap(NormalizeSlashes)).await;
|
||||
|
||||
let req = test::TestRequest::delete().uri(url).to_request();
|
||||
let res = test::call_service(&mut app, req).await;
|
||||
|
18
meilisearch-http/tests/url_normalizer.rs
Normal file
18
meilisearch-http/tests/url_normalizer.rs
Normal file
@ -0,0 +1,18 @@
|
||||
mod common;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn url_normalizer() {
|
||||
let mut server = common::Server::with_uid("movies");
|
||||
|
||||
let (_response, status_code) = server.get_request("/version").await;
|
||||
assert_eq!(status_code, 200);
|
||||
|
||||
let (_response, status_code) = server.get_request("//version").await;
|
||||
assert_eq!(status_code, 200);
|
||||
|
||||
let (_response, status_code) = server.get_request("/version/").await;
|
||||
assert_eq!(status_code, 200);
|
||||
|
||||
let (_response, status_code) = server.get_request("//version/").await;
|
||||
assert_eq!(status_code, 200);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user