1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 00:21:08 +01:00

update tests

This commit is contained in:
Nikolay Kim 2019-03-26 12:31:51 -07:00
parent c7ad677804
commit 50c0ddb3cd
7 changed files with 36 additions and 45 deletions

View File

@ -28,6 +28,7 @@ path = "src/lib.rs"
members = [
".",
"awc",
"actix-http",
"actix-files",
"actix-session",
"actix-web-actors",
@ -71,7 +72,7 @@ actix-utils = "0.3.4"
actix-router = "0.1.0"
actix-rt = "0.2.1"
actix-web-codegen = { path="actix-web-codegen" }
actix-http = { git = "https://github.com/actix/actix-http.git", features=["fail"] }
actix-http = { path = "actix-http", features=["fail"] }
actix-server = "0.4.1"
actix-server-config = "0.1.0"
awc = { path = "awc", optional = true }
@ -105,8 +106,8 @@ openssl = { version="0.10", optional = true }
# rustls = { version = "^0.15", optional = true }
[dev-dependencies]
actix-http = { git = "https://github.com/actix/actix-http.git", features=["ssl"] }
actix-http-test = { git = "https://github.com/actix/actix-http.git", features=["ssl"] }
actix-http = { path = "actix-http", features=["ssl"] }
actix-http-test = { path = "actix-http/test-server", features=["ssl"] }
rand = "0.6"
env_logger = "0.6"
serde_derive = "1.0"

View File

@ -14,6 +14,7 @@ categories = ["network-programming", "asynchronous",
license = "MIT/Apache-2.0"
exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"]
edition = "2018"
workspace = ".."
[package.metadata.docs.rs]
features = ["ssl", "fail", "cookie"]

View File

@ -38,7 +38,7 @@ actix-http = { path=".." }
actix-service = "0.3.4"
actix-server = "0.4.0"
actix-utils = "0.3.4"
awc = { git = "https://github.com/actix/actix-web.git" }
awc = { path = "../../awc" }
base64 = "0.10"
bytes = "0.4"

View File

@ -28,7 +28,7 @@ cookies = ["cookie", "actix-http/cookies"]
[dependencies]
actix-service = "0.3.4"
actix-http = { git = "https://github.com/actix/actix-http.git" }
actix-http = { path = "../actix-http/" }
bytes = "0.4"
futures = "0.1"
log =" 0.4"
@ -44,5 +44,5 @@ openssl = { version="0.10", optional = true }
env_logger = "0.6"
mime = "0.3"
actix-rt = "0.2.1"
actix-http = { git = "https://github.com/actix/actix-http.git", features=["ssl"] }
actix-http-test = { git = "https://github.com/actix/actix-http.git", features=["ssl"] }
actix-http = { path = "../actix-http/", features=["ssl"] }
actix-http-test = { path = "../actix-http/test-server/", features=["ssl"] }

View File

@ -1,4 +1,4 @@
use actix_http::{client, Error};
use actix_http::Error;
use actix_rt::System;
use bytes::BytesMut;
use futures::{future::lazy, Future, Stream};
@ -8,13 +8,10 @@ fn main() -> Result<(), Error> {
env_logger::init();
System::new("test").block_on(lazy(|| {
let mut connector = client::Connector::new().service();
client::ClientRequest::get("https://www.rust-lang.org/") // <- Create request builder
awc::Client::new()
.get("https://www.rust-lang.org/") // <- Create request builder
.header("User-Agent", "Actix-web")
.finish()
.unwrap()
.send(&mut connector) // <- Send http request
.send() // <- Send http request
.from_err()
.and_then(|response| {
// <- server http response

View File

@ -48,23 +48,21 @@ fn test_start() {
});
let (srv, sys) = rx.recv().unwrap();
let mut connector = test::run_on(|| {
let client = test::run_on(|| {
Ok::<_, ()>(
awc::Client::build()
.connector(
client::Connector::new()
.timeout(Duration::from_millis(100))
.service(),
)
.finish(),
)
})
.unwrap();
let host = format!("http://{}", addr);
let response = test::block_on(
client::ClientRequest::get(host.clone())
.finish()
.unwrap()
.send(&mut connector),
)
.unwrap();
let response = test::block_on(client.get(host.clone()).send()).unwrap();
assert!(response.status().is_success());
// stop

View File

@ -45,8 +45,7 @@ fn test_body() {
)
});
let request = srv.get().finish().unwrap();
let mut response = srv.send_request(request).unwrap();
let mut response = srv.block_on(srv.get().send()).unwrap();
assert!(response.status().is_success());
// read response
@ -64,8 +63,7 @@ fn test_body_gzip() {
)
});
let request = srv.get().finish().unwrap();
let mut response = srv.send_request(request).unwrap();
let mut response = srv.block_on(srv.get().send()).unwrap();
assert!(response.status().is_success());
// read response
@ -95,8 +93,7 @@ fn test_body_gzip_large() {
)
});
let request = srv.get().finish().unwrap();
let mut response = srv.send_request(request).unwrap();
let mut response = srv.block_on(srv.get().send()).unwrap();
assert!(response.status().is_success());
// read response
@ -129,8 +126,7 @@ fn test_body_gzip_large_random() {
)
});
let request = srv.get().finish().unwrap();
let mut response = srv.send_request(request).unwrap();
let mut response = srv.block_on(srv.get().send()).unwrap();
assert!(response.status().is_success());
// read response
@ -158,8 +154,7 @@ fn test_body_chunked_implicit() {
)
});
let request = srv.get().finish().unwrap();
let mut response = srv.send_request(request).unwrap();
let mut response = srv.block_on(srv.get().send()).unwrap();
assert!(response.status().is_success());
assert_eq!(
response.headers().get(TRANSFER_ENCODING).unwrap(),
@ -190,8 +185,9 @@ fn test_body_br_streaming() {
)
});
let request = srv.get().header(ACCEPT_ENCODING, "br").finish().unwrap();
let mut response = srv.send_request(request).unwrap();
let mut response = srv
.block_on(srv.get().header(ACCEPT_ENCODING, "br").send())
.unwrap();
assert!(response.status().is_success());
// read response
@ -212,8 +208,7 @@ fn test_head_binary() {
)))
});
let request = srv.head().finish().unwrap();
let mut response = srv.send_request(request).unwrap();
let mut response = srv.block_on(srv.head().send()).unwrap();
assert!(response.status().is_success());
{
@ -239,8 +234,7 @@ fn test_no_chunking() {
))))
});
let request = srv.get().finish().unwrap();
let mut response = srv.send_request(request).unwrap();
let mut response = srv.block_on(srv.get().send()).unwrap();
assert!(response.status().is_success());
assert!(!response.headers().contains_key(TRANSFER_ENCODING));
@ -262,8 +256,7 @@ fn test_body_deflate() {
});
// client request
let request = srv.get().finish().unwrap();
let mut response = srv.send_request(request).unwrap();
let mut response = srv.block_on(srv.get().send()).unwrap();
assert!(response.status().is_success());
// read response
@ -289,8 +282,9 @@ fn test_body_brotli() {
});
// client request
let request = srv.get().header(ACCEPT_ENCODING, "br").finish().unwrap();
let mut response = srv.send_request(request).unwrap();
let mut response = srv
.block_on(srv.get().header(ACCEPT_ENCODING, "br").send())
.unwrap();
assert!(response.status().is_success());
// read response