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 have 2 creates in my project, base and service, and service crate based on base.
And the code is something like this:
crate base {
db.rs
#[mockable]
fun get_users()
}
crate service {
import db;
fun get_users() -> vec<Users>{
let db_users = db.get_users();
if db_users.len() > 0 {
return db_users;
} else {
let users = vec!['a', 'b', 'c']
return users;
}
}
mod test {
import db:get_users()
#[test]
fun test_get_user{
let results = Vec::new();
db.get_users.mock_safe( || MockResult::Return(Ok(results)));
assert_eq(get_users(), vec!['a', 'b', 'c']);
}
}
}
I expect db.get_users() is not called, but mock result returns, but it actually didn't respect the mock and goes to expect the real db.get_users() code.
Does mocktopus support mocking on method in different crate or I made mistakes?
Thanks a lot
The text was updated successfully, but these errors were encountered:
It should be possible. If the dependency is built with mocking enabled for the function, it will be available in the depdendee. You probably should add a special feature gate to enable that, the regular #[cfg(test)] items are not enabled when built as a dependency.
I have 2 creates in my project, base and service, and service crate based on base.
And the code is something like this:
I expect db.get_users() is not called, but mock result returns, but it actually didn't respect the mock and goes to expect the real db.get_users() code.
Does mocktopus support mocking on method in different crate or I made mistakes?
Thanks a lot
The text was updated successfully, but these errors were encountered: