This commit is contained in:
Rob Ede 2021-05-18 17:04:37 +01:00
parent 6353fdc581
commit 93840507e1
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
6 changed files with 13 additions and 18 deletions

View File

@ -1,6 +1,6 @@
[alias]
chk = "hack check --workspace --all-features --tests --examples"
lint = "hack --clean-per-run clippy --workspace --tests --examples"
lint = "clippy --workspace --tests --examples"
ci-min = "hack check --workspace --no-default-features"
ci-min-test = "hack check --workspace --no-default-features --tests --examples"
ci-default = "hack check --workspace"

View File

@ -74,7 +74,7 @@ mod tests {
use actix_utils::future::poll_fn;
use derive_more::{Display, Error};
use futures_core::ready;
use futures_util::{stream, FutureExt};
use futures_util::{stream, FutureExt as _};
use super::*;
use crate::body::to_bytes;
@ -134,7 +134,7 @@ mod tests {
#[derive(Debug)]
enum TimeDelayStream {
Start,
Sleep(#[pin] Sleep),
Sleep(Pin<Box<Sleep>>),
Done,
}
@ -145,24 +145,22 @@ mod tests {
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Self::Item>> {
let this = self.as_mut().project();
match this {
TimeDelayStreamProj::Start => {
match self.as_mut().get_mut() {
TimeDelayStream::Start => {
let sleep = sleep(Duration::from_millis(1));
self.set(TimeDelayStream::Sleep(sleep));
self.as_mut().set(TimeDelayStream::Sleep(Box::pin(sleep)));
cx.waker().wake_by_ref();
Poll::Pending
}
TimeDelayStreamProj::Sleep(mut delay) => {
TimeDelayStream::Sleep(ref mut delay) => {
ready!(delay.poll_unpin(cx));
self.set(TimeDelayStream::Done);
cx.waker().wake_by_ref();
Poll::Pending
}
TimeDelayStreamProj::Done => Poll::Ready(Some(Err(StreamErr))),
TimeDelayStream::Done => Poll::Ready(Some(Err(StreamErr))),
}
}
}

View File

@ -88,7 +88,7 @@ where
header::CONTENT_TYPE,
header::HeaderValue::from_static("text/plain; charset=utf-8"),
);
res.set_body(Body::from(buf.into_inner())).into()
res.set_body(Body::from(buf.into_inner()))
}
InternalErrorType::Response(ref resp) => {

View File

@ -487,7 +487,7 @@ mod tests {
};
let resp =
HttpResponse::BadRequest().body(serde_json::to_string(&msg).unwrap());
InternalError::from_response(err, resp.into()).into()
InternalError::from_response(err, resp).into()
}))
.to_http_parts();

View File

@ -296,11 +296,8 @@ mod tests {
async fn test_custom_err_handler() {
let (req, mut pl) = TestRequest::with_uri("/name/user1/")
.app_data(PathConfig::default().error_handler(|err, _| {
error::InternalError::from_response(
err,
HttpResponse::Conflict().finish().into(),
)
.into()
error::InternalError::from_response(err, HttpResponse::Conflict().finish())
.into()
}))
.to_http_parts();

View File

@ -267,7 +267,7 @@ mod tests {
let req = TestRequest::with_uri("/name/user1/")
.app_data(QueryConfig::default().error_handler(|e, _| {
let resp = HttpResponse::UnprocessableEntity().finish();
InternalError::from_response(e, resp.into()).into()
InternalError::from_response(e, resp).into()
}))
.to_srv_request();