Mocking Clone
#451
-
I have a trait that requires Clone, but I'm having trouble getting it working. I'm not sure what I'm missing, but this is a reduced example I came up with: pub struct Thing;
pub trait Db: Clone {
fn get_things(&self) -> Thing;
}
#[cfg(test)]
mod tests {
use super::*;
use mockall::mock;
#[derive(Clone)]
struct MyDb;
mock! {
MyDb {}
impl Clone for MyDb {
fn clone(&self) -> Self;
}
impl Db for MyDb {
fn get_things(&self) -> Thing;
}
}
#[test]
fn clone_test() {
let db = MockMyDb::new();
db.clone();
}
} With that code when I run
I apologize if I missed something in the documentation or didn't find a relevant discussion, but I haven't been able to find anything in my searches and reading. |
Beta Was this translation helpful? Give feedback.
Answered by
asomers
Jan 17, 2023
Replies: 1 comment 1 reply
-
You did everything correctly, but never wrote any expectations. BTW, you might want to look at https://github.com/asomers/mockall/blob/master/mockall/tests/mock_clone.rs . |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
flounders
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You did everything correctly, but never wrote any expectations. BTW, you might want to look at https://github.com/asomers/mockall/blob/master/mockall/tests/mock_clone.rs .