|
1 | 1 | use std::{borrow::Cow, collections::HashMap, sync::Arc, time::Duration};
|
2 | 2 |
|
3 | 3 | use bson::Document;
|
4 |
| -use serde::Deserialize; |
| 4 | +use serde::{Deserialize, Serialize}; |
5 | 5 | use tokio::sync::{RwLockReadGuard, RwLockWriteGuard};
|
6 | 6 |
|
7 | 7 | use crate::{
|
@@ -976,6 +976,39 @@ async fn manual_shutdown_immediate_with_resources() {
|
976 | 976 | assert!(events.get_command_started_events(&["delete"]).is_empty());
|
977 | 977 | }
|
978 | 978 |
|
| 979 | +#[cfg_attr(feature = "tokio-runtime", tokio::test)] |
| 980 | +#[cfg_attr(feature = "async-std-runtime", async_std::test)] |
| 981 | +async fn find_one_and_delete_serde_consistency() { |
| 982 | + let client = Client::test_builder().build().await; |
| 983 | + |
| 984 | + let coll = client |
| 985 | + .database("find_one_and_delete_serde_consistency") |
| 986 | + .collection("test"); |
| 987 | + |
| 988 | + #[derive(Debug, Serialize, Deserialize)] |
| 989 | + struct Foo { |
| 990 | + #[serde(with = "serde_hex::SerHexSeq::<serde_hex::StrictPfx>")] |
| 991 | + problematic: Vec<u8>, |
| 992 | + } |
| 993 | + |
| 994 | + let doc = Foo { |
| 995 | + problematic: vec![0, 1, 2, 3, 4, 5, 6, 7], |
| 996 | + }; |
| 997 | + |
| 998 | + coll.insert_one(&doc, None).await.unwrap(); |
| 999 | + let rec: Foo = coll.find_one(doc! {}, None).await.unwrap().unwrap(); |
| 1000 | + assert_eq!(doc.problematic, rec.problematic); |
| 1001 | + let rec: Foo = coll |
| 1002 | + .find_one_and_delete(doc! {}, None) |
| 1003 | + .await |
| 1004 | + .unwrap() |
| 1005 | + .unwrap(); |
| 1006 | + assert_eq!(doc.problematic, rec.problematic); |
| 1007 | + |
| 1008 | + let nothing = coll.find_one_and_delete(doc! {}, None).await.unwrap(); |
| 1009 | + assert!(nothing.is_none()); |
| 1010 | +} |
| 1011 | + |
979 | 1012 | // Verifies that `Client::warm_connection_pool` succeeds.
|
980 | 1013 | #[cfg_attr(feature = "tokio-runtime", tokio::test)]
|
981 | 1014 | #[cfg_attr(feature = "async-std-runtime", async_std::test)]
|
|
0 commit comments