mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 19:12:56 +01:00
merge actix-testing into actix-server (#242)
This commit is contained in:
parent
03eb96d6d4
commit
b5eefb4d42
@ -5,7 +5,6 @@ members = [
|
|||||||
"actix-macros",
|
"actix-macros",
|
||||||
"actix-service",
|
"actix-service",
|
||||||
"actix-server",
|
"actix-server",
|
||||||
"actix-testing",
|
|
||||||
"actix-threadpool",
|
"actix-threadpool",
|
||||||
"actix-tls",
|
"actix-tls",
|
||||||
"actix-tracing",
|
"actix-tracing",
|
||||||
@ -20,7 +19,6 @@ actix-rt = { path = "actix-rt" }
|
|||||||
actix-macros = { path = "actix-macros" }
|
actix-macros = { path = "actix-macros" }
|
||||||
actix-server = { path = "actix-server" }
|
actix-server = { path = "actix-server" }
|
||||||
actix-service = { path = "actix-service" }
|
actix-service = { path = "actix-service" }
|
||||||
actix-testing = { path = "actix-testing" }
|
|
||||||
actix-threadpool = { path = "actix-threadpool" }
|
actix-threadpool = { path = "actix-threadpool" }
|
||||||
actix-tls = { path = "actix-tls" }
|
actix-tls = { path = "actix-tls" }
|
||||||
actix-tracing = { path = "actix-tracing" }
|
actix-tracing = { path = "actix-tracing" }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2020-xx-xx
|
## Unreleased - 2020-xx-xx
|
||||||
|
* Merge `actix-testing` to `actix-server` as `test_server` mod.
|
||||||
|
|
||||||
## 2.0.0-beta.1 - 2020-12-28
|
## 2.0.0-beta.1 - 2020-12-28
|
||||||
* Added explicit info log message on accept queue pause. [#215]
|
* Added explicit info log message on accept queue pause. [#215]
|
||||||
|
@ -36,7 +36,6 @@ slab = "0.4"
|
|||||||
tokio = { version = "1", features = ["sync"] }
|
tokio = { version = "1", features = ["sync"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-testing = "2.0.0-beta.1"
|
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
env_logger = "0.8"
|
env_logger = "0.8"
|
||||||
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }
|
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }
|
||||||
|
@ -11,6 +11,7 @@ mod server;
|
|||||||
mod service;
|
mod service;
|
||||||
mod signals;
|
mod signals;
|
||||||
mod socket;
|
mod socket;
|
||||||
|
mod test_server;
|
||||||
mod waker_queue;
|
mod waker_queue;
|
||||||
mod worker;
|
mod worker;
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ pub use self::builder::ServerBuilder;
|
|||||||
pub use self::config::{ServiceConfig, ServiceRuntime};
|
pub use self::config::{ServiceConfig, ServiceRuntime};
|
||||||
pub use self::server::Server;
|
pub use self::server::Server;
|
||||||
pub use self::service::ServiceFactory;
|
pub use self::service::ServiceFactory;
|
||||||
|
pub use self::test_server::TestServer;
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use self::socket::FromStream;
|
pub use self::socket::FromStream;
|
||||||
|
@ -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::sync::mpsc;
|
||||||
use std::{net, thread};
|
use std::{net, thread};
|
||||||
|
|
||||||
use actix_rt::{net::TcpStream, System};
|
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
|
use crate::{Server, ServerBuilder, ServiceFactory};
|
||||||
pub use actix_macros::test;
|
|
||||||
|
|
||||||
/// The `TestServer` type.
|
/// The `TestServer` type.
|
||||||
///
|
///
|
||||||
@ -24,7 +14,7 @@ pub use actix_macros::test;
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use actix_service::fn_service;
|
/// use actix_service::fn_service;
|
||||||
/// use actix_testing::TestServer;
|
/// use actix_server::TestServer;
|
||||||
///
|
///
|
||||||
/// #[actix_rt::main]
|
/// #[actix_rt::main]
|
||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
@ -115,11 +105,10 @@ impl TestServer {
|
|||||||
/// Get first available unused local address
|
/// Get first available unused local address
|
||||||
pub fn unused_addr() -> net::SocketAddr {
|
pub fn unused_addr() -> net::SocketAddr {
|
||||||
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
||||||
let socket =
|
let socket = mio::net::TcpSocket::new_v4().unwrap();
|
||||||
Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
|
socket.bind(addr).unwrap();
|
||||||
socket.bind(&addr.into()).unwrap();
|
socket.set_reuseaddr(true).unwrap();
|
||||||
socket.set_reuse_address(true).unwrap();
|
let tcp = socket.listen(1024).unwrap();
|
||||||
let tcp = socket.into_tcp_listener();
|
|
||||||
tcp.local_addr().unwrap()
|
tcp.local_addr().unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ use super::{IntoServiceFactory, ServiceFactory};
|
|||||||
///
|
///
|
||||||
/// Note that this function consumes the receiving service factory and returns
|
/// Note that this function consumes the receiving service factory and returns
|
||||||
/// a wrapped version of it.
|
/// 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
|
where
|
||||||
I: IntoServiceFactory<SF, Req>,
|
I: IntoServiceFactory<SF, Req>,
|
||||||
SF: ServiceFactory<Req>,
|
SF: ServiceFactory<Req>,
|
||||||
|
@ -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
|
|
@ -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"
|
|
@ -1 +0,0 @@
|
|||||||
../LICENSE-APACHE
|
|
@ -1 +0,0 @@
|
|||||||
../LICENSE-MIT
|
|
@ -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
|
|
@ -77,7 +77,6 @@ tokio-native-tls = { version = "0.3", optional = true }
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-server = "2.0.0-beta.1"
|
actix-server = "2.0.0-beta.1"
|
||||||
actix-testing = "2.0.0-beta.1"
|
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
env_logger = "0.8"
|
env_logger = "0.8"
|
||||||
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }
|
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }
|
||||||
|
@ -2,8 +2,8 @@ use std::io;
|
|||||||
|
|
||||||
use actix_codec::{BytesCodec, Framed};
|
use actix_codec::{BytesCodec, Framed};
|
||||||
use actix_rt::net::TcpStream;
|
use actix_rt::net::TcpStream;
|
||||||
|
use actix_server::TestServer;
|
||||||
use actix_service::{fn_service, Service, ServiceFactory};
|
use actix_service::{fn_service, Service, ServiceFactory};
|
||||||
use actix_testing::TestServer;
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures_util::sink::SinkExt;
|
use futures_util::sink::SinkExt;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user