mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
Updated basics/nested-routing to v4. (#483)
This commit is contained in:
committed by
GitHub
parent
57514aa8d8
commit
bcc9243206
@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user