Upgrade actix-web
to latest beta versions
This commit is contained in:
parent
7bc8a2b79d
commit
09da50b143
2 changed files with 49 additions and 36 deletions
|
@ -13,10 +13,10 @@ subscriptions = ["juniper_graphql_ws", "tokio"]
|
|||
|
||||
[dependencies]
|
||||
actix = "0.12"
|
||||
actix-http = "3.0.0-beta.13"
|
||||
actix-http = "3.0.0-beta.15"
|
||||
http = "0.2.4"
|
||||
actix-web = "4.0.0-beta.12"
|
||||
actix-web-actors = "4.0.0-beta.7"
|
||||
actix-web = "4.0.0-beta.14"
|
||||
actix-web-actors = "4.0.0-beta.8"
|
||||
|
||||
juniper = { version = "0.15.7", path = "../juniper", default-features = false }
|
||||
juniper_graphql_ws = { version = "0.3.0", path = "../juniper_graphql_ws", optional = true }
|
||||
|
@ -30,11 +30,11 @@ tokio = { version = "1.0", features = ["sync"], optional = true }
|
|||
|
||||
[dev-dependencies]
|
||||
actix-rt = "2"
|
||||
actix-cors = "0.6.0-beta.4"
|
||||
actix-identity = "0.4.0-beta.4"
|
||||
actix-cors = "0.6.0-beta.6"
|
||||
actix-identity = "0.4.0-beta.5"
|
||||
tokio = "1.0"
|
||||
async-stream = "0.3"
|
||||
actix-test = "0.1.0-beta.6"
|
||||
actix-test = "0.1.0-beta.8"
|
||||
|
||||
juniper = { version = "0.15.7", path = "../juniper", features = ["expose-test-schema"] }
|
||||
|
||||
|
|
|
@ -466,7 +466,9 @@ pub mod subscriptions {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_http::body::AnyBody;
|
||||
use std::pin::Pin;
|
||||
|
||||
use actix_http::body::MessageBody;
|
||||
use actix_web::{
|
||||
dev::ServiceResponse,
|
||||
http,
|
||||
|
@ -475,6 +477,7 @@ mod tests {
|
|||
web::Data,
|
||||
App,
|
||||
};
|
||||
use futures::future;
|
||||
use juniper::{
|
||||
http::tests::{run_http_test_suite, HttpIntegration, TestResponse},
|
||||
tests::fixtures::starwars::schema::{Database, Query},
|
||||
|
@ -487,11 +490,16 @@ mod tests {
|
|||
type Schema =
|
||||
juniper::RootNode<'static, Query, EmptyMutation<Database>, EmptySubscription<Database>>;
|
||||
|
||||
async fn take_response_body_string(resp: &mut ServiceResponse) -> String {
|
||||
match resp.response().body() {
|
||||
AnyBody::Bytes(body) => String::from_utf8(body.to_vec()).unwrap(),
|
||||
_ => String::from(""),
|
||||
}
|
||||
async fn take_response_body_string(resp: ServiceResponse) -> String {
|
||||
let mut body = resp.into_body();
|
||||
String::from_utf8(
|
||||
future::poll_fn(|cx| Pin::new(&mut body).poll_next(cx))
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.to_vec(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
async fn index(
|
||||
|
@ -537,13 +545,13 @@ mod tests {
|
|||
.append_header((ACCEPT, "text/html"))
|
||||
.to_request();
|
||||
|
||||
let mut resp = test::call_service(&mut app, req).await;
|
||||
let body = take_response_body_string(&mut resp).await;
|
||||
let resp = test::call_service(&mut app, req).await;
|
||||
assert_eq!(resp.status(), http::StatusCode::OK);
|
||||
assert_eq!(
|
||||
resp.headers().get(CONTENT_TYPE).unwrap().to_str().unwrap(),
|
||||
"text/html; charset=utf-8"
|
||||
);
|
||||
let body = take_response_body_string(resp).await;
|
||||
assert!(body.contains("<script>var GRAPHQL_URL = '/dogs-api/graphql';</script>"));
|
||||
assert!(body.contains(
|
||||
"<script>var GRAPHQL_SUBSCRIPTIONS_URL = '/dogs-api/subscriptions';</script>"
|
||||
|
@ -578,13 +586,13 @@ mod tests {
|
|||
.append_header((ACCEPT, "text/html"))
|
||||
.to_request();
|
||||
|
||||
let mut resp = test::call_service(&mut app, req).await;
|
||||
let body = take_response_body_string(&mut resp).await;
|
||||
let resp = test::call_service(&mut app, req).await;
|
||||
assert_eq!(resp.status(), http::StatusCode::OK);
|
||||
assert_eq!(
|
||||
resp.headers().get(CONTENT_TYPE).unwrap().to_str().unwrap(),
|
||||
"text/html; charset=utf-8"
|
||||
);
|
||||
let body = take_response_body_string(resp).await;
|
||||
assert!(body.contains("GraphQLPlayground.init(root, { endpoint: '/dogs-api/graphql', subscriptionEndpoint: '/dogs-api/subscriptions' })"));
|
||||
}
|
||||
|
||||
|
@ -611,17 +619,16 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
|
||||
let mut resp = test::call_service(&mut app, req).await;
|
||||
dbg!(take_response_body_string(&mut resp).await);
|
||||
let resp = test::call_service(&mut app, req).await;
|
||||
assert_eq!(resp.status(), http::StatusCode::OK);
|
||||
assert_eq!(
|
||||
take_response_body_string(&mut resp).await,
|
||||
r#"{"data":{"hero":{"name":"R2-D2"}}}"#
|
||||
);
|
||||
assert_eq!(
|
||||
resp.headers().get("content-type").unwrap(),
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(
|
||||
take_response_body_string(resp).await,
|
||||
r#"{"data":{"hero":{"name":"R2-D2"}}}"#
|
||||
);
|
||||
}
|
||||
|
||||
#[actix_web::rt::test]
|
||||
|
@ -644,17 +651,17 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
|
||||
let mut resp = test::call_service(&mut app, req).await;
|
||||
let resp = test::call_service(&mut app, req).await;
|
||||
|
||||
assert_eq!(resp.status(), http::StatusCode::OK);
|
||||
assert_eq!(
|
||||
take_response_body_string(&mut resp).await,
|
||||
r#"{"data":{"hero":{"name":"R2-D2"}}}"#
|
||||
);
|
||||
assert_eq!(
|
||||
resp.headers().get("content-type").unwrap(),
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(
|
||||
take_response_body_string(resp).await,
|
||||
r#"{"data":{"hero":{"name":"R2-D2"}}}"#
|
||||
);
|
||||
}
|
||||
|
||||
#[actix_web::rt::test]
|
||||
|
@ -688,17 +695,17 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
|
||||
let mut resp = test::call_service(&mut app, req).await;
|
||||
let resp = test::call_service(&mut app, req).await;
|
||||
|
||||
assert_eq!(resp.status(), http::StatusCode::OK);
|
||||
assert_eq!(
|
||||
take_response_body_string(&mut resp).await,
|
||||
r#"[{"data":{"hero":{"name":"R2-D2"}}},{"data":{"hero":{"id":"1000","name":"Luke Skywalker"}}}]"#
|
||||
);
|
||||
assert_eq!(
|
||||
resp.headers().get("content-type").unwrap(),
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(
|
||||
take_response_body_string(resp).await,
|
||||
r#"[{"data":{"hero":{"name":"R2-D2"}}},{"data":{"hero":{"id":"1000","name":"Luke Skywalker"}}}]"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -757,14 +764,20 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
async fn make_test_response(mut resp: ServiceResponse) -> TestResponse {
|
||||
let body = take_response_body_string(&mut resp).await;
|
||||
async fn make_test_response(resp: ServiceResponse) -> TestResponse {
|
||||
let status_code = resp.status().as_u16();
|
||||
let content_type = resp.headers().get(CONTENT_TYPE).unwrap();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get(CONTENT_TYPE)
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_string();
|
||||
let body = take_response_body_string(resp).await;
|
||||
TestResponse {
|
||||
status_code: status_code as i32,
|
||||
body: Some(body),
|
||||
content_type: content_type.to_str().unwrap().to_string(),
|
||||
content_type,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue