How do I execute a line of code only when it is for unit tests? Say I have the following function:
fn foo() {
let run_this = true;
If run_this {
connect_to_internet();
}
}
When foo() gets ran for a unit test, I want run_this to be set to false. I tried doing something like:
Let mut run_this = true;
#[cfg(test)] {
run_this = false;
}
But it’s not working as expected