1
0
mirror of https://github.com/actix/examples synced 2024-11-27 16:02:57 +01: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:
Luca Palmieri 2022-02-02 15:15:25 +00:00 committed by GitHub
parent 663807baa0
commit 5dec713add
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 113 deletions

172
Cargo.lock generated
View File

@ -1150,7 +1150,7 @@ dependencies = [
name = "async_data_factory"
version = "1.0.0"
dependencies = [
"actix-web 3.3.3",
"actix-web 4.0.0-rc.1",
"num_cpus",
"redis",
"redis_tang",
@ -1186,7 +1186,7 @@ dependencies = [
name = "async_pg"
version = "1.0.0"
dependencies = [
"actix-web 3.3.3",
"actix-web 4.0.0-rc.1",
"config",
"deadpool-postgres",
"derive_more",
@ -1449,7 +1449,7 @@ dependencies = [
"chrono",
"hex",
"lazy_static",
"linked-hash-map 0.5.4",
"linked-hash-map",
"rand 0.7.3",
"serde 1.0.136",
"serde_json",
@ -1733,12 +1733,12 @@ version = "4.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50b727aacc797f9fc28e355d21f34709ac4fc9adecfe470ad07b8f4464f53062"
dependencies = [
"bytes 0.5.6",
"bytes 1.1.0",
"futures-core",
"memchr",
"pin-project-lite 0.2.8",
"tokio 0.2.25",
"tokio 1.16.1",
"tokio-util 0.6.9",
]
[[package]]
@ -1752,9 +1752,9 @@ dependencies = [
[[package]]
name = "config"
version = "0.10.1"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b076e143e1d9538dde65da30f8481c2a6c44040edb8e02b9bf1351edb92ce3"
checksum = "1b1b9d958c2b1368a663f05538fc1b5975adce1e19f435acceae987aceeeb369"
dependencies = [
"lazy_static",
"nom 5.1.2",
@ -1919,17 +1919,6 @@ dependencies = [
"crossbeam-utils 0.8.6",
]
[[package]]
name = "crossbeam-queue"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
dependencies = [
"cfg-if 0.1.10",
"crossbeam-utils 0.7.2",
"maybe-uninit",
]
[[package]]
name = "crossbeam-queue"
version = "0.3.3"
@ -1970,16 +1959,6 @@ dependencies = [
"generic-array 0.14.5",
]
[[package]]
name = "crypto-mac"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58bcd97a54c7ca5ce2f6eb16f6bede5b0ab5f0055fedc17d2f0b4466e21671ca"
dependencies = [
"generic-array 0.14.5",
"subtle",
]
[[package]]
name = "crypto-mac"
version = "0.10.1"
@ -2096,34 +2075,39 @@ checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57"
[[package]]
name = "deadpool"
version = "0.5.2"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4aaff9a7a1de9893f4004fa08527b31cb2ae4121c44e053cf53f29203c73bd23"
checksum = "3bf0c5365c0925c80a838a6810a1bf38d3304ca6b4eb25829e29e33da12de786"
dependencies = [
"async-trait",
"config",
"crossbeam-queue 0.2.3",
"deadpool-runtime",
"num_cpus",
"serde 1.0.136",
"tokio 0.2.25",
"tokio 1.16.1",
]
[[package]]
name = "deadpool-postgres"
version = "0.5.6"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "faad41e7f93dd682108c72aec029e5bc6238e7df64c9d84832525d4033d2e726"
checksum = "46ff1451a33b8b31b15eedcf5401dbbb28606caed4fa94d20487eb3fac2ebd04"
dependencies = [
"async-trait",
"config",
"deadpool",
"futures",
"log",
"serde 1.0.136",
"tokio 0.2.25",
"tokio 1.16.1",
"tokio-postgres",
]
[[package]]
name = "deadpool-runtime"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaa37046cc0f6c3cc6090fbdbf73ef0b8ef4cfcc37f6befc0020f63e8cf121e1"
dependencies = [
"tokio 1.16.1",
]
[[package]]
name = "derivative"
version = "2.2.0"
@ -2837,16 +2821,6 @@ dependencies = [
"hmac 0.12.0",
]
[[package]]
name = "hmac"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "deae6d9dbb35ec2c502d62b8f7b1c000a0822c3b0794ba36b3149c0a1c840dff"
dependencies = [
"crypto-mac 0.9.1",
"digest 0.9.0",
]
[[package]]
name = "hmac"
version = "0.10.1"
@ -3411,16 +3385,6 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "linked-hash-map"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd"
dependencies = [
"serde 0.8.23",
"serde_test",
]
[[package]]
name = "linked-hash-map"
version = "0.5.4"
@ -3482,7 +3446,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c"
dependencies = [
"linked-hash-map 0.5.4",
"linked-hash-map",
]
[[package]]
@ -3541,10 +3505,13 @@ dependencies = [
]
[[package]]
name = "md5"
version = "0.7.0"
name = "md-5"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
checksum = "e6a38fc55c8bbc10058782919516f88826e70320db6d206aebc49611d24216ae"
dependencies = [
"digest 0.10.1",
]
[[package]]
name = "memchr"
@ -3720,7 +3687,7 @@ dependencies = [
"hex",
"hmac 0.11.0",
"lazy_static",
"md-5",
"md-5 0.9.1",
"os_info",
"pbkdf2",
"percent-encoding",
@ -4360,29 +4327,29 @@ dependencies = [
[[package]]
name = "postgres-protocol"
version = "0.5.3"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4888a0e36637ab38d76cace88c1476937d617ad015f07f6b669cec11beacc019"
checksum = "79ec03bce71f18b4a27c4c64c6ba2ddf74686d69b91d8714fb32ead3adaed713"
dependencies = [
"base64 0.13.0",
"byteorder",
"bytes 0.5.6",
"bytes 1.1.0",
"fallible-iterator",
"hmac 0.9.0",
"md5",
"hmac 0.12.0",
"md-5 0.10.0",
"memchr",
"rand 0.7.3",
"sha2 0.9.9",
"rand 0.8.4",
"sha2 0.10.1",
"stringprep",
]
[[package]]
name = "postgres-types"
version = "0.1.3"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfc08a7d94a80665de4a83942fa8db2fdeaf2f123fc0535e384dc4fff251efae"
checksum = "04619f94ba0cc80999f4fc7073607cb825bc739a883cb6d20900fc5e009d6b0d"
dependencies = [
"bytes 0.5.6",
"bytes 1.1.0",
"fallible-iterator",
"postgres-protocol",
]
@ -4660,20 +4627,20 @@ dependencies = [
[[package]]
name = "redis"
version = "0.16.0"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b94c6247d45d78d24481a5b7aca146f414ec0f5e39e175f294d1876b943eeeb"
checksum = "1a6ddfecac9391fed21cce10e83c65fa4abafd77df05c98b1c647c65374ce9b3"
dependencies = [
"async-trait",
"bytes 0.5.6",
"bytes 1.1.0",
"combine 4.6.3",
"dtoa",
"futures-util",
"itoa 0.4.8",
"percent-encoding",
"pin-project-lite 0.1.12",
"tokio 0.2.25",
"tokio-util 0.3.1",
"pin-project-lite 0.2.8",
"tokio 1.16.1",
"tokio-util 0.6.9",
"url",
]
@ -4711,13 +4678,13 @@ dependencies = [
[[package]]
name = "redis_tang"
version = "0.1.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c59bde1154e309b06974b93bdffe1b948473a0a1b350bc4222f4c1f37a90058d"
checksum = "028e4e2639af069271f0681968c11a34ec2d7b726fddbd087964fde34b52f99a"
dependencies = [
"redis",
"tang-rs",
"tokio 0.2.25",
"tokio 1.16.1",
]
[[package]]
@ -4943,7 +4910,7 @@ dependencies = [
"http",
"hyper 0.14.16",
"log",
"md-5",
"md-5 0.9.1",
"percent-encoding",
"pin-project-lite 0.2.8",
"rusoto_credential",
@ -5220,7 +5187,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8"
dependencies = [
"lazy_static",
"linked-hash-map 0.3.0",
"num-traits 0.1.43",
"regex",
"serde 0.8.23",
@ -5258,15 +5224,6 @@ dependencies = [
"serde 1.0.136",
]
[[package]]
name = "serde_test"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5"
dependencies = [
"serde 0.8.23",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@ -5562,7 +5519,7 @@ dependencies = [
"bytes 1.1.0",
"crc",
"crossbeam-channel 0.5.2",
"crossbeam-queue 0.3.3",
"crossbeam-queue",
"crossbeam-utils 0.8.6",
"either",
"futures-channel",
@ -6145,18 +6102,18 @@ dependencies = [
[[package]]
name = "tokio-pg-mapper"
version = "0.1.8"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9e1579e20815e41802b181613c30eaa3cb3ac2a0691683f3dcd9c96e5cfa799"
checksum = "93f2b78f3566383ffabc553c72bbb2f129962a54886c5c4d8e8c706f84eceab8"
dependencies = [
"tokio-postgres",
]
[[package]]
name = "tokio-pg-mapper-derive"
version = "0.1.5"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b6945ad3b3b9f035740a75b59b8fa0708514485967649d931255cd5acd4e614"
checksum = "8548f756cd6eb4069c5af0fb0cec57001fb42bd1fb7330d8f24067ee3fa62608"
dependencies = [
"quote",
"syn",
@ -6165,24 +6122,25 @@ dependencies = [
[[package]]
name = "tokio-postgres"
version = "0.5.5"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55a2482c9fe4dd481723cf5c0616f34afc710e55dcda0944e12e7b3316117892"
checksum = "4b6c8b33df661b548dcd8f9bf87debb8c56c05657ed291122e1188698c2ece95"
dependencies = [
"async-trait",
"byteorder",
"bytes 0.5.6",
"bytes 1.1.0",
"fallible-iterator",
"futures",
"log",
"parking_lot",
"percent-encoding",
"phf 0.8.0",
"pin-project-lite 0.1.12",
"phf 0.10.1",
"pin-project-lite 0.2.8",
"postgres-protocol",
"postgres-types",
"tokio 0.2.25",
"tokio-util 0.3.1",
"socket2 0.4.4",
"tokio 1.16.1",
"tokio-util 0.6.9",
]
[[package]]
@ -7103,7 +7061,7 @@ version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [
"linked-hash-map 0.5.4",
"linked-hash-map",
]
[[package]]

View File

@ -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"] }

View File

@ -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);
}