From b719dc4d8e87a5d95cf996df11aec7873c2c336b Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 1 Dec 2024 17:02:51 +0100 Subject: [PATCH] Add tests for moving a commit across an update-ref todo This works correctly, we just didn't have test coverage for it. --- pkg/utils/rebase_todo_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pkg/utils/rebase_todo_test.go b/pkg/utils/rebase_todo_test.go index 4896c8a1d..ea2bd5968 100644 --- a/pkg/utils/rebase_todo_test.go +++ b/pkg/utils/rebase_todo_test.go @@ -64,6 +64,21 @@ func TestRebaseCommands_moveTodoDown(t *testing.T) { {Command: todo.Pick, Commit: "5678"}, }, }, + { + testName: "move across update-ref todo", + todos: []todo.Todo{ + {Command: todo.Pick, Commit: "1234"}, + {Command: todo.UpdateRef, Ref: "refs/heads/some_branch"}, + {Command: todo.Pick, Commit: "5678"}, + }, + todoToMoveDown: Todo{Hash: "5678"}, + expectedErr: "", + expectedTodos: []todo.Todo{ + {Command: todo.Pick, Commit: "1234"}, + {Command: todo.Pick, Commit: "5678"}, + {Command: todo.UpdateRef, Ref: "refs/heads/some_branch"}, + }, + }, { testName: "skip an invisible todo", todos: []todo.Todo{ @@ -190,6 +205,21 @@ func TestRebaseCommands_moveTodoUp(t *testing.T) { {Command: todo.UpdateRef, Ref: "refs/heads/some_branch"}, }, }, + { + testName: "move across update-ref todo", + todos: []todo.Todo{ + {Command: todo.Pick, Commit: "1234"}, + {Command: todo.UpdateRef, Ref: "refs/heads/some_branch"}, + {Command: todo.Pick, Commit: "5678"}, + }, + todoToMoveUp: Todo{Hash: "1234"}, + expectedErr: "", + expectedTodos: []todo.Todo{ + {Command: todo.UpdateRef, Ref: "refs/heads/some_branch"}, + {Command: todo.Pick, Commit: "1234"}, + {Command: todo.Pick, Commit: "5678"}, + }, + }, { testName: "skip an invisible todo", todos: []todo.Todo{