I've modeled and implemented a car using an extern crate inside the implementation:
extern crate speed_control;
struct Car;
trait SpeedControl {
fn increase(&self) -> Result<(), ()>;
fn decrease(&self) -> Result<(), ()>;
}
impl SpeedControl for Car {
fn increase(&self) -> Result<(), ()> {
match speed_control::increase() { // Here I use the dependency
// ...
}
}
// ...
}
I want to test the implementation above, but in my tests I don't want speed_control::increase()
to behave like it was in production - I want to mock it. How can I achieve this?