mirror of
https://github.com/actix/examples
synced 2025-06-28 09:50:36 +02:00
Update database-interactions/mongo-db to the latest v4 beta (#508)
Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
@ -4,8 +4,7 @@ version = "1.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "2.2.0"
|
||||
actix-web = "4.0.0-beta.8"
|
||||
actix-web = "4.0.0-beta.21"
|
||||
futures-util = "0.3.17"
|
||||
mongodb = "2.0.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
@ -1,12 +1,12 @@
|
||||
use actix_web::{
|
||||
test::{init_service, read_response, read_response_json, TestRequest},
|
||||
test::{call_and_read_body, call_and_read_body_json, init_service, TestRequest},
|
||||
web::Bytes,
|
||||
};
|
||||
use mongodb::Client;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
#[actix_web::test]
|
||||
#[ignore = "requires MongoDB instance running"]
|
||||
async fn test() {
|
||||
let uri = std::env::var("MONGODB_URI")
|
||||
@ -42,13 +42,13 @@ async fn test() {
|
||||
.set_form(&user)
|
||||
.to_request();
|
||||
|
||||
let response = read_response(&mut app, req).await;
|
||||
let response = call_and_read_body(&mut app, req).await;
|
||||
assert_eq!(response, Bytes::from_static(b"user added"));
|
||||
|
||||
let req = TestRequest::get()
|
||||
.uri(&format!("/get_user/{}", &user.username))
|
||||
.to_request();
|
||||
|
||||
let response: User = read_response_json(&mut app, req).await;
|
||||
let response: User = call_and_read_body_json(&mut app, req).await;
|
||||
assert_eq!(response, user);
|
||||
}
|
||||
|
Reference in New Issue
Block a user