mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-26 15:07:42 +02:00
add trybuild tests to routing codegen (#1677)
This commit is contained in:
25
actix-web-codegen/tests/trybuild/simple-fail.rs
Normal file
25
actix-web-codegen/tests/trybuild/simple-fail.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use actix_web::*;
|
||||
|
||||
#[get("/one", other)]
|
||||
async fn one() -> impl Responder {
|
||||
HttpResponse::Ok()
|
||||
}
|
||||
|
||||
#[post(/two)]
|
||||
async fn two() -> impl Responder {
|
||||
HttpResponse::Ok()
|
||||
}
|
||||
|
||||
static PATCH_PATH: &str = "/three";
|
||||
|
||||
#[patch(PATCH_PATH)]
|
||||
async fn three() -> impl Responder {
|
||||
HttpResponse::Ok()
|
||||
}
|
||||
|
||||
#[delete("/four", "/five")]
|
||||
async fn four() -> impl Responder {
|
||||
HttpResponse::Ok()
|
||||
}
|
||||
|
||||
fn main() {}
|
23
actix-web-codegen/tests/trybuild/simple-fail.stderr
Normal file
23
actix-web-codegen/tests/trybuild/simple-fail.stderr
Normal file
@ -0,0 +1,23 @@
|
||||
error: Unknown attribute.
|
||||
--> $DIR/simple-fail.rs:3:15
|
||||
|
|
||||
3 | #[get("/one", other)]
|
||||
| ^^^^^
|
||||
|
||||
error: expected identifier or literal
|
||||
--> $DIR/simple-fail.rs:8:8
|
||||
|
|
||||
8 | #[post(/two)]
|
||||
| ^
|
||||
|
||||
error: Unknown attribute.
|
||||
--> $DIR/simple-fail.rs:15:9
|
||||
|
|
||||
15 | #[patch(PATCH_PATH)]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: Multiple paths specified! Should be only one!
|
||||
--> $DIR/simple-fail.rs:20:19
|
||||
|
|
||||
20 | #[delete("/four", "/five")]
|
||||
| ^^^^^^^
|
15
actix-web-codegen/tests/trybuild/simple.rs
Normal file
15
actix-web-codegen/tests/trybuild/simple.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use actix_web::*;
|
||||
|
||||
#[get("/config")]
|
||||
async fn config() -> impl Responder {
|
||||
HttpResponse::Ok()
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() {
|
||||
let srv = test::start(|| App::new().service(config));
|
||||
|
||||
let request = srv.get("/config");
|
||||
let response = request.send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
}
|
Reference in New Issue
Block a user