Skip to content

is it possible to mock a Arc::new(self.clone()) in the trait? #382

Answered by ymwjbxxq
ymwjbxxq asked this question in Questions
Discussion options

You must be logged in to vote

I would like to have a professional opinion (it is my second day with mockAll) on how I solve the issue:

         let mut mock = MockMyStruct::default();
        //mock.expect_add_query().times(1).returning(move |_| Ok(()));
        mock.expect_clone_to_arc().times(1).returning(move || {
            let mut m = MockMyStruct::new();
            m.expect_add_query().times(1).returning(|_| Ok(())); // .times(1) is not working  I can put 100 and it still fine
            Arc::new(m)
        });

Does it make sense, or there is a better way to do it?

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@asomers
Comment options

@ymwjbxxq
Comment options

@asomers
Comment options

@ymwjbxxq
Comment options

Answer selected by ymwjbxxq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants