diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index f0f6ef6146..d0c34f31f4 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -228,6 +228,15 @@ impl Client { self.http.clone() } + #[cfg(any(test, feature = "test-support"))] + pub fn tear_down(&self) { + let mut state = self.state.write(); + state.message_handlers.clear(); + state.models_by_message_type.clear(); + state.models_by_entity_type_and_remote_id.clear(); + state.entity_id_extractors.clear(); + } + #[cfg(any(test, feature = "test-support"))] pub fn override_authenticate(&mut self, authenticate: F) -> &mut Self where diff --git a/crates/server/src/rpc.rs b/crates/server/src/rpc.rs index 7b376eca35..af5ee8aa84 100644 --- a/crates/server/src/rpc.rs +++ b/crates/server/src/rpc.rs @@ -5052,6 +5052,12 @@ mod tests { } } + impl Drop for TestClient { + fn drop(&mut self) { + self.client.tear_down(); + } + } + impl Executor for Arc { fn spawn_detached>(&self, future: F) { self.spawn(future).detach();