mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 06:39:22 +02:00
migrate integration testing to new crate (#2112)
This commit is contained in:
@ -4,7 +4,7 @@ use std::task::{Context, Poll};
|
||||
use actix_utils::future;
|
||||
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
|
||||
use actix_web::http::header::{HeaderName, HeaderValue};
|
||||
use actix_web::{http, test, web::Path, App, Error, HttpResponse, Responder};
|
||||
use actix_web::{http, web::Path, App, Error, HttpResponse, Responder};
|
||||
use actix_web_codegen::{connect, delete, get, head, options, patch, post, put, route, trace};
|
||||
use futures_core::future::LocalBoxFuture;
|
||||
|
||||
@ -149,7 +149,7 @@ async fn get_wrap(_: Path<String>) -> impl Responder {
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_params() {
|
||||
let srv = test::start(|| {
|
||||
let srv = actix_test::start(|| {
|
||||
App::new()
|
||||
.service(get_param_test)
|
||||
.service(put_param_test)
|
||||
@ -171,7 +171,7 @@ async fn test_params() {
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_body() {
|
||||
let srv = test::start(|| {
|
||||
let srv = actix_test::start(|| {
|
||||
App::new()
|
||||
.service(post_test)
|
||||
.service(put_test)
|
||||
@ -245,7 +245,7 @@ async fn test_body() {
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_auto_async() {
|
||||
let srv = test::start(|| App::new().service(auto_async));
|
||||
let srv = actix_test::start(|| App::new().service(auto_async));
|
||||
|
||||
let request = srv.request(http::Method::GET, srv.url("/test"));
|
||||
let response = request.send().await.unwrap();
|
||||
@ -254,7 +254,7 @@ async fn test_auto_async() {
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_wrap() {
|
||||
let srv = test::start(|| App::new().service(get_wrap));
|
||||
let srv = actix_test::start(|| App::new().service(get_wrap));
|
||||
|
||||
let request = srv.request(http::Method::GET, srv.url("/test/wrap"));
|
||||
let response = request.send().await.unwrap();
|
||||
|
@ -1,7 +1,7 @@
|
||||
use actix_web::{Responder, HttpResponse, App, test};
|
||||
use actix_web::{Responder, HttpResponse, App};
|
||||
use actix_web_codegen::*;
|
||||
|
||||
/// Docstrings shouldn't break anything.
|
||||
/// doc comments shouldn't break anything
|
||||
#[get("/")]
|
||||
async fn index() -> impl Responder {
|
||||
HttpResponse::Ok()
|
||||
@ -9,7 +9,7 @@ async fn index() -> impl Responder {
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() {
|
||||
let srv = test::start(|| App::new().service(index));
|
||||
let srv = actix_test::start(|| App::new().service(index));
|
||||
|
||||
let request = srv.get("/");
|
||||
let response = request.send().await.unwrap();
|
||||
|
@ -7,9 +7,9 @@ async fn index() -> String {
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() {
|
||||
use actix_web::{App, test};
|
||||
use actix_web::App;
|
||||
|
||||
let srv = test::start(|| App::new().service(index));
|
||||
let srv = actix_test::start(|| App::new().service(index));
|
||||
|
||||
let request = srv.get("/");
|
||||
let response = request.send().await.unwrap();
|
||||
|
@ -5,7 +5,7 @@ error: HTTP method defined more than once: `GET`
|
||||
| ^^^^^
|
||||
|
||||
error[E0425]: cannot find value `index` in this scope
|
||||
--> $DIR/route-duplicate-method-fail.rs:12:49
|
||||
--> $DIR/route-duplicate-method-fail.rs:12:55
|
||||
|
|
||||
12 | let srv = test::start(|| App::new().service(index));
|
||||
| ^^^^^ not found in this scope
|
||||
12 | let srv = actix_test::start(|| App::new().service(index));
|
||||
| ^^^^^ not found in this scope
|
||||
|
@ -7,9 +7,9 @@ async fn index() -> String {
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() {
|
||||
use actix_web::{App, test};
|
||||
use actix_web::App;
|
||||
|
||||
let srv = test::start(|| App::new().service(index));
|
||||
let srv = actix_test::start(|| App::new().service(index));
|
||||
|
||||
let request = srv.get("/");
|
||||
let response = request.send().await.unwrap();
|
||||
|
@ -7,7 +7,7 @@ error: The #[route(..)] macro requires at least one `method` attribute
|
||||
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0425]: cannot find value `index` in this scope
|
||||
--> $DIR/route-missing-method-fail.rs:12:49
|
||||
--> $DIR/route-missing-method-fail.rs:12:55
|
||||
|
|
||||
12 | let srv = test::start(|| App::new().service(index));
|
||||
| ^^^^^ not found in this scope
|
||||
12 | let srv = actix_test::start(|| App::new().service(index));
|
||||
| ^^^^^ not found in this scope
|
||||
|
@ -7,9 +7,9 @@ async fn index() -> String {
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() {
|
||||
use actix_web::{App, test};
|
||||
use actix_web::App;
|
||||
|
||||
let srv = test::start(|| App::new().service(index));
|
||||
let srv = actix_test::start(|| App::new().service(index));
|
||||
|
||||
let request = srv.get("/");
|
||||
let response = request.send().await.unwrap();
|
||||
|
@ -7,9 +7,9 @@ async fn index() -> String {
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() {
|
||||
use actix_web::{App, test};
|
||||
use actix_web::App;
|
||||
|
||||
let srv = test::start(|| App::new().service(index));
|
||||
let srv = actix_test::start(|| App::new().service(index));
|
||||
|
||||
let request = srv.get("/");
|
||||
let response = request.send().await.unwrap();
|
||||
|
@ -5,7 +5,7 @@ error: Unexpected HTTP method: `UNEXPECTED`
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error[E0425]: cannot find value `index` in this scope
|
||||
--> $DIR/route-unexpected-method-fail.rs:12:49
|
||||
--> $DIR/route-unexpected-method-fail.rs:12:55
|
||||
|
|
||||
12 | let srv = test::start(|| App::new().service(index));
|
||||
| ^^^^^ not found in this scope
|
||||
12 | let srv = actix_test::start(|| App::new().service(index));
|
||||
| ^^^^^ not found in this scope
|
||||
|
@ -1,4 +1,4 @@
|
||||
use actix_web::{Responder, HttpResponse, App, test};
|
||||
use actix_web::{Responder, HttpResponse, App};
|
||||
use actix_web_codegen::*;
|
||||
|
||||
#[get("/config")]
|
||||
@ -8,7 +8,7 @@ async fn config() -> impl Responder {
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() {
|
||||
let srv = test::start(|| App::new().service(config));
|
||||
let srv = actix_test::start(|| App::new().service(config));
|
||||
|
||||
let request = srv.get("/config");
|
||||
let response = request.send().await.unwrap();
|
||||
|
Reference in New Issue
Block a user