I am trying to test code in rust using Mocks from the mockall crate.
#[automock]
trait MyTrait {
fn some_func(&self) -> i64;
}
struct MyStruct {
data: Arc<dyn MyTrait>
}
impl MyStruct {
// ... lots of code
}
#[test]
fn a_test() {
let mut mock = MockMyTrait::new();
mock.expect_some_func().return_const(42);
let testee = MyStruct { data: Arc::new(mock) };
// test a lot of code from MyStruct
// here I want to call 'mock.chekcpoint()' and setup more expectations
// test some more MyStruct code
}
Since the mock is now moved into the Arc I do not know how I can access the checkpoint method of the mock object. Is there a way to get access to the Mock object or is there a better way for me to structure my code to make testing easier/possible ?