@@ -5,13 +5,12 @@ use actix_rt::{net::TcpStream, System};
55
66use crate :: { Server , ServerBuilder , ServiceFactory } ;
77
8- /// The `TestServer` type .
8+ /// A testing server .
99///
10- /// `TestServer` is very simple test server that simplify process of writing
11- /// integration tests for actix-net applications.
10+ /// `TestServer` is very simple test server that simplify process of writing integration tests for
11+ /// network applications.
1212///
1313/// # Examples
14- ///
1514/// ```
1615/// use actix_service::fn_service;
1716/// use actix_server::TestServer;
@@ -39,7 +38,7 @@ pub struct TestServerRuntime {
3938}
4039
4140impl TestServer {
42- /// Start new server with server builder
41+ /// Start new server with server builder.
4342 pub fn start < F > ( mut factory : F ) -> TestServerRuntime
4443 where
4544 F : FnMut ( ServerBuilder ) -> ServerBuilder + Send + ' static ,
@@ -64,7 +63,7 @@ impl TestServer {
6463 }
6564 }
6665
67- /// Start new test server with application factory
66+ /// Start new test server with application factory.
6867 pub fn with < F : ServiceFactory < TcpStream > > ( factory : F ) -> TestServerRuntime {
6968 let ( tx, rx) = mpsc:: channel ( ) ;
7069
@@ -99,7 +98,7 @@ impl TestServer {
9998 }
10099 }
101100
102- /// Get first available unused local address
101+ /// Get first available unused local address.
103102 pub fn unused_addr ( ) -> net:: SocketAddr {
104103 let addr: net:: SocketAddr = "127.0.0.1:0" . parse ( ) . unwrap ( ) ;
105104 let socket = mio:: net:: TcpSocket :: new_v4 ( ) . unwrap ( ) ;
@@ -111,27 +110,27 @@ impl TestServer {
111110}
112111
113112impl TestServerRuntime {
114- /// Test server host
113+ /// Test server host.
115114 pub fn host ( & self ) -> & str {
116115 & self . host
117116 }
118117
119- /// Test server port
118+ /// Test server port.
120119 pub fn port ( & self ) -> u16 {
121120 self . port
122121 }
123122
124- /// Get test server address
123+ /// Get test server address.
125124 pub fn addr ( & self ) -> net:: SocketAddr {
126125 self . addr
127126 }
128127
129- /// Stop http server
128+ /// Stop server.
130129 fn stop ( & mut self ) {
131130 self . system . stop ( ) ;
132131 }
133132
134- /// Connect to server, return tokio TcpStream
133+ /// Connect to server, returning a Tokio ` TcpStream`.
135134 pub fn connect ( & self ) -> std:: io:: Result < TcpStream > {
136135 TcpStream :: from_std ( net:: TcpStream :: connect ( self . addr ) ?)
137136 }
0 commit comments