1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-24 07:53:00 +01:00

fix tests for no-default-features

This commit is contained in:
Nikolay Kim 2019-03-28 14:27:07 -07:00
parent a2c9ff3a33
commit 878f32c495
4 changed files with 47 additions and 22 deletions

View File

@ -34,7 +34,8 @@ before_script:
- export PATH=$PATH:~/.cargo/bin
script:
- cargo clean
- cargo update
- cargo check --all --no-default-features
- cargo test --all-features --all -- --nocapture
# Upload docs

View File

@ -10,6 +10,7 @@ use actix_service::boxed::{self, BoxedNewService};
use actix_service::{
ApplyTransform, IntoNewService, IntoTransform, NewService, Transform,
};
#[cfg(any(feature = "brotli", feature = "flate2-zlib", feature = "flate2-rust"))]
use bytes::Bytes;
use futures::{IntoFuture, Stream};

View File

@ -2,9 +2,8 @@ use net2::TcpBuilder;
use std::sync::mpsc;
use std::{net, thread, time::Duration};
use actix_http::{client, Response};
use actix_web::{test, web, App, HttpServer};
use actix_http::Response;
use actix_web::{web, App, HttpServer};
fn unused_addr() -> net::SocketAddr {
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
@ -48,6 +47,11 @@ fn test_start() {
});
let (srv, sys) = rx.recv().unwrap();
#[cfg(feature = "client")]
{
use actix_http::client;
use actix_web::test;
let client = test::run_on(|| {
Ok::<_, ()>(
awc::Client::build()
@ -64,6 +68,7 @@ fn test_start() {
let response = test::block_on(client.get(host.clone()).send()).unwrap();
assert!(response.status().is_success());
}
// stop
let _ = srv.stop(false);

View File

@ -11,10 +11,13 @@ use bytes::Bytes;
use flate2::read::GzDecoder;
use flate2::write::{GzEncoder, ZlibDecoder, ZlibEncoder};
use flate2::Compression;
use futures::stream::once; //Future, Stream
use futures::stream::once;
use rand::{distributions::Alphanumeric, Rng};
use actix_web::{dev::HttpMessageBody, middleware::encoding, web, App};
use actix_web::{dev::HttpMessageBody, web, App};
#[cfg(any(feature = "brotli", feature = "flate2-zlib", feature = "flate2-rust"))]
use actix_web::middleware::encoding;
const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
Hello World Hello World Hello World Hello World Hello World \
@ -55,6 +58,7 @@ fn test_body() {
assert_eq!(bytes, Bytes::from_static(STR.as_ref()));
}
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
#[test]
fn test_body_gzip() {
let mut srv = TestServer::new(|| {
@ -78,6 +82,7 @@ fn test_body_gzip() {
assert_eq!(Bytes::from(dec), Bytes::from_static(STR.as_ref()));
}
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
#[test]
fn test_body_encoding_override() {
let mut srv = TestServer::new(|| {
@ -104,6 +109,7 @@ fn test_body_encoding_override() {
assert_eq!(Bytes::from(dec), Bytes::from_static(STR.as_ref()));
}
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
#[test]
fn test_body_gzip_large() {
let data = STR.repeat(10);
@ -134,6 +140,7 @@ fn test_body_gzip_large() {
assert_eq!(Bytes::from(dec), Bytes::from(data));
}
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
#[test]
fn test_body_gzip_large_random() {
let data = rand::thread_rng()
@ -168,6 +175,7 @@ fn test_body_gzip_large_random() {
assert_eq!(Bytes::from(dec), Bytes::from(data));
}
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
#[test]
fn test_body_chunked_implicit() {
let mut srv = TestServer::new(move || {
@ -200,6 +208,7 @@ fn test_body_chunked_implicit() {
}
#[test]
#[cfg(feature = "brotli")]
fn test_body_br_streaming() {
let mut srv = TestServer::new(move || {
h1::H1Service::new(
@ -277,6 +286,7 @@ fn test_no_chunking() {
}
#[test]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
fn test_body_deflate() {
let mut srv = TestServer::new(move || {
h1::H1Service::new(
@ -303,6 +313,7 @@ fn test_body_deflate() {
}
#[test]
#[cfg(any(feature = "brotli"))]
fn test_body_brotli() {
let mut srv = TestServer::new(move || {
h1::H1Service::new(
@ -336,6 +347,7 @@ fn test_body_brotli() {
}
#[test]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
fn test_encoding() {
let mut srv = TestServer::new(move || {
HttpService::new(
@ -364,6 +376,7 @@ fn test_encoding() {
}
#[test]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
fn test_gzip_encoding() {
let mut srv = TestServer::new(move || {
HttpService::new(
@ -392,6 +405,7 @@ fn test_gzip_encoding() {
}
#[test]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
fn test_gzip_encoding_large() {
let data = STR.repeat(10);
let mut srv = TestServer::new(move || {
@ -421,6 +435,7 @@ fn test_gzip_encoding_large() {
}
#[test]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
fn test_reading_gzip_encoding_large_random() {
let data = rand::thread_rng()
.sample_iter(&Alphanumeric)
@ -455,6 +470,7 @@ fn test_reading_gzip_encoding_large_random() {
}
#[test]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
fn test_reading_deflate_encoding() {
let mut srv = TestServer::new(move || {
h1::H1Service::new(
@ -483,6 +499,7 @@ fn test_reading_deflate_encoding() {
}
#[test]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
fn test_reading_deflate_encoding_large() {
let data = STR.repeat(10);
let mut srv = TestServer::new(move || {
@ -512,6 +529,7 @@ fn test_reading_deflate_encoding_large() {
}
#[test]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
fn test_reading_deflate_encoding_large_random() {
let data = rand::thread_rng()
.sample_iter(&Alphanumeric)
@ -545,8 +563,8 @@ fn test_reading_deflate_encoding_large_random() {
assert_eq!(bytes, Bytes::from(data));
}
#[cfg(feature = "brotli")]
#[test]
#[cfg(feature = "brotli")]
fn test_brotli_encoding() {
let mut srv = TestServer::new(move || {
h1::H1Service::new(