mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-21 04:46:29 +03:00
Add tests for IsHeadCommit
This commit is contained in:
1 parent
02be5e74ed
commit
d673a0f3b9
1 file changed
+29
@@ -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})
|
||||
}
|
||||
Reference in new issue
Block a user