1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-23 20:51:06 +01:00

merge actix-testing into actix-server (#242)

This commit is contained in:
fakeshadow 2020-12-30 05:20:24 +08:00 committed by GitHub
parent 03eb96d6d4
commit b5eefb4d42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 11 additions and 98 deletions

View File

@ -5,7 +5,6 @@ members = [
"actix-macros",
"actix-service",
"actix-server",
"actix-testing",
"actix-threadpool",
"actix-tls",
"actix-tracing",
@ -20,7 +19,6 @@ actix-rt = { path = "actix-rt" }
actix-macros = { path = "actix-macros" }
actix-server = { path = "actix-server" }
actix-service = { path = "actix-service" }
actix-testing = { path = "actix-testing" }
actix-threadpool = { path = "actix-threadpool" }
actix-tls = { path = "actix-tls" }
actix-tracing = { path = "actix-tracing" }

View File

@ -1,7 +1,7 @@
# Changes
## Unreleased - 2020-xx-xx
* Merge `actix-testing` to `actix-server` as `test_server` mod.
## 2.0.0-beta.1 - 2020-12-28
* Added explicit info log message on accept queue pause. [#215]

View File

@ -36,7 +36,6 @@ slab = "0.4"
tokio = { version = "1", features = ["sync"] }
[dev-dependencies]
actix-testing = "2.0.0-beta.1"
bytes = "1"
env_logger = "0.8"
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }

View File

@ -11,6 +11,7 @@ mod server;
mod service;
mod signals;
mod socket;
mod test_server;
mod waker_queue;
mod worker;
@ -18,6 +19,7 @@ pub use self::builder::ServerBuilder;
pub use self::config::{ServiceConfig, ServiceRuntime};
pub use self::server::Server;
pub use self::service::ServiceFactory;
pub use self::test_server::TestServer;
#[doc(hidden)]
pub use self::socket::FromStream;

View File

@ -1,19 +1,9 @@
//! Various helpers for Actix applications to use during testing.
#![deny(rust_2018_idioms, nonstandard_style)]
#![allow(clippy::type_complexity, clippy::needless_doctest_main)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
use std::sync::mpsc;
use std::{net, thread};
use actix_rt::{net::TcpStream, System};
use actix_server::{Server, ServerBuilder, ServiceFactory};
use socket2::{Domain, Protocol, Socket, Type};
#[cfg(not(test))] // Work around for rust-lang/rust#62127
pub use actix_macros::test;
use crate::{Server, ServerBuilder, ServiceFactory};
/// The `TestServer` type.
///
@ -24,7 +14,7 @@ pub use actix_macros::test;
///
/// ```rust
/// use actix_service::fn_service;
/// use actix_testing::TestServer;
/// use actix_server::TestServer;
///
/// #[actix_rt::main]
/// async fn main() {
@ -115,11 +105,10 @@ impl TestServer {
/// Get first available unused local address
pub fn unused_addr() -> net::SocketAddr {
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
let socket =
Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
socket.bind(&addr.into()).unwrap();
socket.set_reuse_address(true).unwrap();
let tcp = socket.into_tcp_listener();
let socket = mio::net::TcpSocket::new_v4().unwrap();
socket.bind(addr).unwrap();
socket.set_reuseaddr(true).unwrap();
let tcp = socket.listen(1024).unwrap();
tcp.local_addr().unwrap()
}
}

View File

@ -6,7 +6,7 @@ use super::{IntoServiceFactory, ServiceFactory};
///
/// Note that this function consumes the receiving service factory and returns
/// a wrapped version of it.
pub fn map_config<I, SF, S, Req, F, Cfg>(factory: I, f: F) -> MapConfig<SF, Req, F, Cfg>
pub fn map_config<I, SF, Req, F, Cfg>(factory: I, f: F) -> MapConfig<SF, Req, F, Cfg>
where
I: IntoServiceFactory<SF, Req>,
SF: ServiceFactory<Req>,

View File

@ -1,37 +0,0 @@
# Changes
## Unreleased - 2021-xx-xx
## 2.0.0-beta.1 - 2020-12-28
* Update `actix-server` to v2.0.0-beta.1.
## 1.0.1 - 2020-05-19
* Replace deprecated `net2` crate with `socket2`
* Remove unused `futures` dependency
## 1.0.0 - 2019-12-11
* Update actix-server to 1.0.0
## 1.0.0-alpha.3 - 2019-12-07
* Migrate to tokio 0.2
## 1.0.0-alpha.2 - 2019-12-02
* Re-export `test` attribute macros
## 0.3.0-alpha.1 - 2019-11-22
* Migrate to std::future
## 0.2.0 - 2019-10-14
* Upgrade actix-server and actix-server-config deps
## 0.1.0 - 2019-09-25
* Initial impl

View File

@ -1,26 +0,0 @@
[package]
name = "actix-testing"
version = "2.0.0-beta.1"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Various helpers for Actix applications to use during testing"
keywords = ["network", "framework", "async", "futures"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-testing/"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
edition = "2018"
readme = "README.md"
[lib]
name = "actix_testing"
path = "src/lib.rs"
[dependencies]
actix-rt = "2.0.0-beta.1"
actix-macros = "0.1.0"
actix-server = "2.0.0-beta.1"
actix-service = "2.0.0-beta.1"
log = "0.4"
socket2 = "0.3"

View File

@ -1 +0,0 @@
../LICENSE-APACHE

View File

@ -1 +0,0 @@
../LICENSE-MIT

View File

@ -1,9 +0,0 @@
# Actix test utilities [![crates.io](https://meritbadge.herokuapp.com/actix-testing)](https://crates.io/crates/actix-testint) [![Join the chat at https://gitter.im/actix/actix](https://badges.gitter.im/actix/actix.svg)](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## Documentation & community resources
* [User Guide](https://actix.rs/docs/)
* [API Documentation](https://docs.rs/actix-testing/)
* [Chat on gitter](https://gitter.im/actix/actix)
* Cargo package: [actix-http-test](https://crates.io/crates/actix-testing)
* Minimum supported Rust version: 1.46 or later

View File

@ -77,7 +77,6 @@ tokio-native-tls = { version = "0.3", optional = true }
[dev-dependencies]
actix-server = "2.0.0-beta.1"
actix-testing = "2.0.0-beta.1"
bytes = "1"
env_logger = "0.8"
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }

View File

@ -2,8 +2,8 @@ use std::io;
use actix_codec::{BytesCodec, Framed};
use actix_rt::net::TcpStream;
use actix_server::TestServer;
use actix_service::{fn_service, Service, ServiceFactory};
use actix_testing::TestServer;
use bytes::Bytes;
use futures_util::sink::SinkExt;