From d673a0f3b90b8dfcaa3606e236c0cbec370bf331 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 22 Jun 2026 09:02:11 +0200 Subject: [PATCH] Add tests for IsHeadCommit --- pkg/commands/models/commit_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pkg/commands/models/commit_test.go diff --git a/pkg/commands/models/commit_test.go b/pkg/commands/models/commit_test.go new file mode 100644 index 000000000..d24238023 --- /dev/null +++ b/pkg/commands/models/commit_test.go @@ -0,0 +1,29 @@ +package models + +import ( + "testing" + + "github.com/jesseduffield/lazygit/pkg/utils" + "github.com/stefanhaller/git-todo-parser/todo" + "github.com/stretchr/testify/assert" +) + +func TestIsHeadCommit(t *testing.T) { + commits := []*Commit{ + makeTestTodoCommit(todo.Pick), + makeTestCommit("a"), + makeTestCommit("b"), + } + + assert.False(t, IsHeadCommit(commits, 0)) + assert.True(t, IsHeadCommit(commits, 1)) + assert.False(t, IsHeadCommit(commits, 2)) +} + +func makeTestCommit(hash string) *Commit { + return NewCommit(&utils.StringPool{}, NewCommitOpts{Hash: hash}) +} + +func makeTestTodoCommit(action todo.TodoCommand) *Commit { + return NewCommit(&utils.StringPool{}, NewCommitOpts{Action: action}) +}