test(xy): reload diff
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
mod common;
|
||||||
|
use common::*;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn reload_adds_removes_and_changes() {
|
||||||
|
let xy = xy_bin();
|
||||||
|
let sleeper = sleep_server_bin();
|
||||||
|
let mut h = Harness::new();
|
||||||
|
h.write_server("a", sleeper.to_str().unwrap(), 19_020, "always");
|
||||||
|
h.start_daemon(&xy).await;
|
||||||
|
|
||||||
|
for _ in 0..40 {
|
||||||
|
let (_c, out, _e) = h.run_cli(&xy, &["list"]).await;
|
||||||
|
if out.contains("a") && out.contains("running") {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
h.write_server("a", sleeper.to_str().unwrap(), 19_021, "always");
|
||||||
|
h.write_server("b", sleeper.to_str().unwrap(), 19_022, "always");
|
||||||
|
let (code, out, _e) = h.run_cli(&xy, &["reload"]).await;
|
||||||
|
assert_eq!(code, 0);
|
||||||
|
assert!(out.contains("added:") && out.contains("b"), "stdout: {out}");
|
||||||
|
assert!(
|
||||||
|
out.contains("changed:") && out.contains("a"),
|
||||||
|
"stdout: {out}"
|
||||||
|
);
|
||||||
|
|
||||||
|
std::fs::remove_file(h.config_dir.join("a.kdl")).unwrap();
|
||||||
|
let (code, out, _e) = h.run_cli(&xy, &["reload"]).await;
|
||||||
|
assert_eq!(code, 0);
|
||||||
|
assert!(
|
||||||
|
out.contains("removed:") && out.contains("a"),
|
||||||
|
"stdout: {out}"
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user