Automock a trait with Clone

Hi Rustaceans,

I'm trying to use mocking in my tests. I have an HTTP client which complicate some unit tests ...

I have a trait which require Clone :

#[automock]
pub trait TracimClient: Clone {
    fn trash(&self, content_id: ContentId) -> Result<(), TracimClientError>;
}

But, when using automock macro (from mockall), it seems automock do not support the Clone requirement :

error[E0277]: the trait bound `MockTracimClient: Clone` is not satisfied
  --> core/src/client.rs:23:11
   |
23 | pub trait TracimClient: Clone {
   |           ^^^^^^^^^^^^ the trait `Clone` is not implemented for `MockTracimClient`
   |
note: required by a bound in `TracimClient`
  --> core/src/client.rs:23:25
   |
23 | pub trait TracimClient: Clone {
   |                         ^^^^^ required by this bound in `TracimClient`

I have no idea about how to solve that. I found some info about mockall and Clone but only about structs.

Ideas ?

You should read the section of mockall documentation on inherited traits mockall - Rust

Thanks I will take a look !

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.