1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

reduce futures dep

This commit is contained in:
Rob Ede
2022-03-06 00:15:16 +00:00
parent c5f2a8fcc7
commit e8cd22d2f2
25 changed files with 62 additions and 59 deletions

View File

@ -71,3 +71,23 @@ async fn main() -> std::io::Result<()> {
.run()
.await
}
#[cfg(test)]
mod tests {
use actix_web::test::{self, TestRequest};
use super::*;
#[actix_web::test]
async fn api_versioning() {
let app = test::init_service(create_app()).await;
let req = TestRequest::with_uri("/api/hello").insert_header(("Accept-Version", "1"));
let res = test::call_and_read_body(&app, req.to_request()).await;
assert_eq!(res, "Hello World from v1 API!");
let req = TestRequest::with_uri("/api/hello").insert_header(("Accept-Version", "2"));
let res = test::call_and_read_body(&app, req.to_request()).await;
assert_eq!(res, "Hello World from the awesome new v2 API!");
}
}