mod common;
use common::{OutputAssertions, TestRepo};
#[test]
fn test_abort_no_rebase_in_progress() {
let repo = TestRepo::new();
repo.run_stax(&["status"]).assert_success();
let output = repo.run_stax(&["abort"]);
output.assert_success();
let stdout = TestRepo::stdout(&output);
assert!(
stdout.contains("Nothing to abort"),
"Expected 'Nothing to abort' message, got: {}",
stdout
);
}
#[test]
fn test_abort_during_rebase_conflict() {
let repo = TestRepo::new();
repo.run_stax(&["status"]).assert_success();
let branch_name = repo.create_conflict_scenario();
let _output = repo.run_stax(&["restack"]);
if repo.has_rebase_in_progress() {
let output = repo.run_stax(&["abort"]);
output.assert_success();
let stdout = TestRepo::stdout(&output);
assert!(
stdout.contains("aborted"),
"Expected abort confirmation, got: {}",
stdout
);
assert!(
!repo.has_rebase_in_progress(),
"Rebase should no longer be in progress after abort"
);
} else {
let output = repo.run_stax(&["abort"]);
output.assert_success();
}
assert!(
repo.current_branch().contains("conflict") || repo.current_branch() == branch_name,
"Expected to still be on the conflict branch"
);
}
#[test]
fn test_abort_returns_clean_state() {
let repo = TestRepo::new();
repo.run_stax(&["status"]).assert_success();
repo.create_stack(&["feature-a"]);
let output = repo.run_stax(&["abort"]);
output.assert_success();
output.assert_stdout_contains("Nothing to abort");
}