update relevant changes from master

This commit is contained in:
mpostma
2021-03-10 14:43:10 +01:00
parent 5ecf514d28
commit 0cd8869349
16 changed files with 276 additions and 26 deletions

View File

@ -2,7 +2,7 @@ use std::time::Duration;
use actix_web::http::StatusCode;
use serde_json::{json, Value};
use tokio::time::sleep;
use tokio::time::delay_for;
use super::service::Service;
@ -79,7 +79,7 @@ impl Index<'_> {
return response;
}
sleep(Duration::from_secs(1)).await;
delay_for(Duration::from_secs(1)).await;
}
panic!("Timeout waiting for update id");
}

View File

@ -1,7 +1,8 @@
use tempdir::TempDir;
use actix_web::http::StatusCode;
use byte_unit::{Byte, ByteUnit};
use serde_json::Value;
use actix_web::http::StatusCode;
use tempdir::TempDir;
use urlencoding::encode;
use meilisearch_http::data::Data;
use meilisearch_http::option::{Opt, IndexerOpts};
@ -60,7 +61,7 @@ impl Server {
/// Returns a view to an index. There is no guarantee that the index exists.
pub fn index<'a>(&'a self, uid: impl AsRef<str>) -> Index<'a> {
Index {
uid: uid.as_ref().to_string(),
uid: encode(uid.as_ref()),
service: &self.service,
}
}

View File

@ -2,14 +2,14 @@ use actix_web::{http::StatusCode, test};
use serde_json::Value;
use meilisearch_http::data::Data;
use meilisearch_http::create_app;
use meilisearch_http::helpers::NormalizePath;
pub struct Service(pub Data);
impl Service {
pub async fn post(&self, url: impl AsRef<str>, body: Value) -> (Value, StatusCode) {
let mut app =
test::init_service(create_app!(&self.0, true)).await;
test::init_service(meilisearch_http::create_app(&self.0, true).wrap(NormalizePath)).await;
let req = test::TestRequest::post()
.uri(url.as_ref())
@ -26,12 +26,12 @@ impl Service {
/// Send a test post request from a text body, with a `content-type:application/json` header.
pub async fn post_str(&self, url: impl AsRef<str>, body: impl AsRef<str>) -> (Value, StatusCode) {
let mut app =
test::init_service(create_app!(&self.0, true)).await;
test::init_service(meilisearch_http::create_app(&self.0, true).wrap(NormalizePath)).await;
let req = test::TestRequest::post()
.uri(url.as_ref())
.set_payload(body.as_ref().to_string())
.insert_header(("content-type", "application/json"))
.header("content-type", "application/json")
.to_request();
let res = test::call_service(&mut app, req).await;
let status_code = res.status();
@ -43,7 +43,7 @@ impl Service {
pub async fn get(&self, url: impl AsRef<str>) -> (Value, StatusCode) {
let mut app =
test::init_service(create_app!(&self.0, true)).await;
test::init_service(meilisearch_http::create_app(&self.0, true).wrap(NormalizePath)).await;
let req = test::TestRequest::get().uri(url.as_ref()).to_request();
let res = test::call_service(&mut app, req).await;
@ -56,7 +56,7 @@ impl Service {
pub async fn put(&self, url: impl AsRef<str>, body: Value) -> (Value, StatusCode) {
let mut app =
test::init_service(create_app!(&self.0, true)).await;
test::init_service(meilisearch_http::create_app(&self.0, true).wrap(NormalizePath)).await;
let req = test::TestRequest::put()
.uri(url.as_ref())
@ -72,7 +72,7 @@ impl Service {
pub async fn delete(&self, url: impl AsRef<str>) -> (Value, StatusCode) {
let mut app =
test::init_service(create_app!(&self.0, true)).await;
test::init_service(meilisearch_http::create_app(&self.0, true).wrap(NormalizePath)).await;
let req = test::TestRequest::delete().uri(url.as_ref()).to_request();
let res = test::call_service(&mut app, req).await;