mirror of
https://github.com/actix/examples
synced 2024-11-27 16:02:57 +01:00
Updated basics/nested-routing to v4. (#483)
This commit is contained in:
parent
57514aa8d8
commit
bcc9243206
@ -2,17 +2,11 @@
|
|||||||
name = "async_ex2"
|
name = "async_ex2"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["dowwie <dkcdkg@gmail.com>"]
|
authors = ["dowwie <dkcdkg@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = { version = "3", features = ["openssl"] }
|
actix-web = { version = "4.0.0-beta.21", features = ["openssl"] }
|
||||||
actix-service = "1.0.0"
|
env_logger = "0.9"
|
||||||
bytes = "0.5.3"
|
|
||||||
env_logger = "0.8"
|
|
||||||
futures = "0.3.1"
|
|
||||||
serde = { version = "^1.0", features = ["derive"] }
|
serde = { version = "^1.0", features = ["derive"] }
|
||||||
serde_json = "1.0.39"
|
serde_json = "1.0.39"
|
||||||
time = "0.1.42"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
actix-rt = "1"
|
|
||||||
|
@ -25,21 +25,21 @@ pub async fn remove_product(_id: web::Path<String>) -> Result<HttpResponse, Erro
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::appconfig::config_app;
|
use crate::appconfig::config_app;
|
||||||
use actix_service::Service;
|
use actix_web::dev::Service;
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
http::{header, StatusCode},
|
http::{header, StatusCode},
|
||||||
test, App,
|
test, App,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_web::test]
|
||||||
async fn test_add_product() {
|
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 payload = r#"{"id":12345,"product_type":"fancy","name":"test"}"#.as_bytes();
|
||||||
|
|
||||||
let req = test::TestRequest::post()
|
let req = test::TestRequest::post()
|
||||||
.uri("/products")
|
.uri("/products")
|
||||||
.header(header::CONTENT_TYPE, "application/json")
|
.insert_header((header::CONTENT_TYPE, "application/json"))
|
||||||
.set_payload(payload)
|
.set_payload(payload)
|
||||||
.to_request();
|
.to_request();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user