diff --git a/src/lib.rs b/src/lib.rs index f8cdb67f..62a21a02 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,18 @@ 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,); + } }