use super::*;
#[test]
fn file_changes_survive_a_cancel_so_the_caller_still_refreshes() {
let mut s = panel();
let mut remove = ok_remove();
s.begin_command("d gpu-runner");
s.run_command(&mut remove);
let close = close_outcome(false, &s);
assert_eq!(close.apply, None);
assert_eq!(close.changes, vec!["removed backend 'gpu-runner'"]);
}
#[test]
fn the_save_note_flags_a_same_named_inline_entry() {
let path = std::path::Path::new("/home/x/.newt/backends/dgx1.toml");
let plain = saved_note("dgx1", path, false);
assert_eq!(
plain,
"saved backend 'dgx1' → /home/x/.newt/backends/dgx1.toml"
);
let shared = saved_note("dgx1", path, true);
assert!(shared.starts_with(&plain), "keeps the plain summary");
assert!(shared.contains("[[backends]]") && shared.contains("re-inherited"));
assert_eq!(
BackendSource::UserDropInOverInline.provenance(),
"drop-in + inline entry"
);
assert!(BackendSource::UserDropInOverInline.editable());
}
#[test]
fn an_io_error_still_carries_the_committed_file_changes() {
let mut s = panel();
let mut remove = ok_remove();
s.begin_command("d gpu-runner");
s.run_command(&mut remove); let err = finish(Err(io::Error::other("terminal detached")), true, &s)
.expect_err("an io error is still an error");
assert!(err.error.to_string().contains("terminal detached"));
assert_eq!(
err.close.changes,
vec!["removed backend 'gpu-runner'"],
"the committed change survives for the caller to report + re-resolve"
);
assert_eq!(err.close.apply, None, "an aborted panel applies nothing");
let early: PanelRunError = io::Error::other("no raw mode").into();
assert_eq!(early.close, PanelClose::cancelled());
assert_eq!(
finish(Ok(()), false, &s).unwrap().changes,
vec!["removed backend 'gpu-runner'"]
);
}