Consider my struct WareHouse which has a watch function which takes a closure as an argument.
The struct also has an update function which updates a path and a value, and should then call the closure passed into the watch function if applicable.
How can I verify that when I call watch(callback) followed by an update the callback function is triggered?
I tried:
#[test]
fn calls_watcher_on_update() {
let mut w = WareHouse::new();
let mut called = false;
// set a watcher
w.watch(move|| {
println!("watcher called");
called = true;
});
w.update("/foo", "baz").unwrap();
assert!(called);
}