1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00

Updated basics/nested-routing to v4. (#483)

This commit is contained in:
Christopher Gubbin 2022-01-30 21:51:32 +00:00 committed by GitHub
parent 57514aa8d8
commit bcc9243206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 13 deletions

View File

@ -2,17 +2,11 @@
name = "async_ex2"
version = "0.1.0"
authors = ["dowwie <dkcdkg@gmail.com>"]
edition = "2018"
edition = "2021"
[dependencies]
actix-web = { version = "3", features = ["openssl"] }
actix-service = "1.0.0"
bytes = "0.5.3"
env_logger = "0.8"
futures = "0.3.1"
actix-web = { version = "4.0.0-beta.21", features = ["openssl"] }
env_logger = "0.9"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "1.0.39"
time = "0.1.42"
[dev-dependencies]
actix-rt = "1"

View File

@ -25,21 +25,21 @@ pub async fn remove_product(_id: web::Path<String>) -> Result<HttpResponse, Erro
#[cfg(test)]
mod tests {
use crate::appconfig::config_app;
use actix_service::Service;
use actix_web::dev::Service;
use actix_web::{
http::{header, StatusCode},
test, App,
};
#[actix_rt::test]
#[actix_web::test]
async fn test_add_product() {
let mut app = test::init_service(App::new().configure(config_app)).await;
let app = test::init_service(App::new().configure(config_app)).await;
let payload = r#"{"id":12345,"product_type":"fancy","name":"test"}"#.as_bytes();
let req = test::TestRequest::post()
.uri("/products")
.header(header::CONTENT_TYPE, "application/json")
.insert_header((header::CONTENT_TYPE, "application/json"))
.set_payload(payload)
.to_request();