You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw in #152 that DatabaseConnection was not marked Clone if mocks are enabled, but I see now that the Mock connection variant is behind an Arc.
Is there any reason not to make DatbaseConnectionClone? We've stuffed it into an Arc in our application code, but my code reviewers are questioning why the Arc is necessary.
The text was updated successfully, but these errors were encountered:
Yes he is right. Do not stuff an Arc in your app code.
Add a feature in your Cargo, and only enable Mock while in testing.
The reason behind that is Mock has a mock output buffer and a transaction log, where it will be hard to reason it's behaviour when being cloned and used across multiple threads.
It seems like DatabaseConnection::MockDatabaseConnection has inner mock connection struct in an Arc, making it cloneable.
It seems strange that all variants of this DatabaseConnection derives Clone including Arc<MockDatabaseConnection>, but the wrapper enum itself does not implement Clone when mock feature is enabled.
I saw in #152 that
DatabaseConnection
was not markedClone
if mocks are enabled, but I see now that the Mock connection variant is behind anArc
.Is there any reason not to make
DatbaseConnection
Clone
? We've stuffed it into anArc
in our application code, but my code reviewers are questioning why theArc
is necessary.The text was updated successfully, but these errors were encountered: