mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Make equalHash more correct
So far it didn't have to handle the case where one hash is empty and the other isn't, but in the next commit we need that, so let's handle that case correctly. There's enough logic in the function now that it's worth covering it with tests.
This commit is contained in:
@ -2,6 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stefanhaller/git-todo-parser/todo"
|
||||
@ -453,3 +454,26 @@ func TestRebaseCommands_deleteTodos(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_equalHash(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
a string
|
||||
b string
|
||||
expected bool
|
||||
}{
|
||||
{"", "", true},
|
||||
{"", "123", false},
|
||||
{"123", "", false},
|
||||
{"123", "123", true},
|
||||
{"123", "123abc", true},
|
||||
{"123abc", "123", true},
|
||||
{"123", "a", false},
|
||||
{"1", "abc", false},
|
||||
}
|
||||
|
||||
for _, scenario := range scenarios {
|
||||
t.Run(fmt.Sprintf("'%s' vs. '%s'", scenario.a, scenario.b), func(t *testing.T) {
|
||||
assert.Equal(t, scenario.expected, equalHash(scenario.a, scenario.b))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user