mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Add tests for IsHeadCommit
This commit is contained in:
parent
02be5e74ed
commit
d673a0f3b9
29
pkg/commands/models/commit_test.go
Normal file
29
pkg/commands/models/commit_test.go
Normal file
|
|
@ -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})
|
||||
}
|
||||
Loading…
Reference in a new issue