From c41621ba882beeb227663f983d0c86b0ffe668eb Mon Sep 17 00:00:00 2001 From: xolra0d Date: Sat, 9 Aug 2025 03:54:28 +0300 Subject: [PATCH 1/2] Added 2 tests, explained Client::clone --- src/lib.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index f8cdb67f..fa2447a8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,6 +37,12 @@ mod rowbinary; mod ticks; /// A client containing HTTP pool. +/// +/// ### Cloning behavior +/// Clones share the same HTTP transport but store their own configurations. +/// Any `with_*` configuration method (e.g., [`Client::with_option`]) applies +/// only to future clones, because [`Client::clone`] creates a deep copy +/// of the [`Client`] configuration, except the transport. #[derive(Clone)] pub struct Client { http: Arc, @@ -518,4 +524,25 @@ mod client_tests { let client = client.with_validation(true); assert!(client.validation); } + + #[test] + fn it_does_follow_previous_configuration() { + let client = Client::default() + .with_option("async_insert", "1"); + assert_eq!( + client.options, + client.clone().options, + ); + } + + #[test] + fn it_does_not_follow_future_configuration() { + let client = Client::default(); + let client_clone = client.clone(); + let client = client.with_option("async_insert", "1"); + assert_ne!( + client.options, + client_clone.options, + ); + } } From f53cba5595b2f6310f6358f04e90b14c02e8635e Mon Sep 17 00:00:00 2001 From: xolra0d Date: Tue, 19 Aug 2025 20:14:31 +0300 Subject: [PATCH 2/2] fixed formatting issues --- src/lib.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fa2447a8..62a21a02 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -525,14 +525,10 @@ mod client_tests { assert!(client.validation); } - #[test] + #[test] fn it_does_follow_previous_configuration() { - let client = Client::default() - .with_option("async_insert", "1"); - assert_eq!( - client.options, - client.clone().options, - ); + let client = Client::default().with_option("async_insert", "1"); + assert_eq!(client.options, client.clone().options,); } #[test] @@ -540,9 +536,6 @@ mod client_tests { let client = Client::default(); let client_clone = client.clone(); let client = client.with_option("async_insert", "1"); - assert_ne!( - client.options, - client_clone.options, - ); + assert_ne!(client.options, client_clone.options,); } }