Skip to content

Commit 1a446d1

Browse files
committed
test: update rebase conflict test for state tracking format
Update rebase_subcommand_conflict test to verify new --continue/--abort instructions in error output, state file lifecycle, and the --continue recovery flow after resolving conflicts.
1 parent e419c84 commit 1a446d1

1 file changed

Lines changed: 39 additions & 5 deletions

File tree

tests/rebase.rs

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,31 +341,65 @@ chain_name
341341
stderr
342342
);
343343
assert!(
344-
stderr.contains("Resolve any rebase merge conflicts, and then run git chain rebase"),
345-
"stderr should contain resolution instructions, got: {}",
344+
stderr.contains("rebase --continue"),
345+
"stderr should contain --continue instructions, got: {}",
346+
stderr
347+
);
348+
assert!(
349+
stderr.contains("rebase --abort"),
350+
"stderr should contain --abort instructions, got: {}",
346351
stderr
347352
);
348353

349354
assert_eq!(repo.state(), RepositoryState::RebaseInteractive);
350355

356+
// Verify state file was created during conflict
357+
let state_file = path_to_repo.join(".git/chain-rebase-state.json");
358+
assert!(
359+
state_file.exists(),
360+
"chain rebase state file should exist after conflict"
361+
);
362+
363+
// Resolve conflict and complete git-level rebase
351364
commit_all(&repo, "add conflict");
352365
run_git_command(&path_to_repo, vec!["rebase", "--continue"]);
353366

354367
assert_eq!(repo.state(), RepositoryState::Clean);
355368
assert_eq!(&get_current_branch_name(&repo), "some_branch_2");
356369

370+
// Complete the chain rebase
371+
let args: Vec<&str> = vec!["rebase", "--continue"];
372+
let output = run_test_bin_expect_ok(&path_to_repo, args);
373+
374+
let stdout = String::from_utf8_lossy(&output.stdout).to_string();
375+
println!("CONTINUE STDOUT: {}", stdout);
376+
assert!(
377+
stdout.contains("Continuing chain rebase"),
378+
"should show continue message, got: {}",
379+
stdout
380+
);
381+
382+
// Verify state file was cleaned up
383+
assert!(
384+
!state_file.exists(),
385+
"chain rebase state file should be cleaned up after successful continue"
386+
);
387+
388+
// After --continue, we should be back on the original branch (some_branch_1)
389+
assert_eq!(&get_current_branch_name(&repo), "some_branch_1");
390+
357391
// git chain
358392
let args: Vec<&str> = vec![];
359393
let output = run_test_bin_expect_ok(&path_to_repo, args);
360394

361395
assert_eq!(
362396
String::from_utf8_lossy(&output.stdout),
363397
r#"
364-
On branch: some_branch_2
398+
On branch: some_branch_1
365399
366400
chain_name
367-
some_branch_2 ⦁ 1 ahead
368-
some_branch_1 ⦁ 2 ahead
401+
some_branch_2 ⦁ 1 ahead
402+
some_branch_1 ⦁ 2 ahead
369403
master (root branch)
370404
"#
371405
.trim_start()

0 commit comments

Comments
 (0)