mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Improve name handling
This commit is contained in:
52
pkg/commands/git_commands/worktree_loader_test.go
Normal file
52
pkg/commands/git_commands/worktree_loader_test.go
Normal file
@ -0,0 +1,52 @@
|
||||
package git_commands
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetUniqueNamesFromPaths(t *testing.T) {
|
||||
for _, scenario := range []struct {
|
||||
input []string
|
||||
expected []string
|
||||
}{
|
||||
{
|
||||
input: []string{},
|
||||
expected: []string{},
|
||||
},
|
||||
{
|
||||
input: []string{
|
||||
"/my/path/feature/one",
|
||||
},
|
||||
expected: []string{
|
||||
"one",
|
||||
},
|
||||
},
|
||||
{
|
||||
input: []string{
|
||||
"/my/path/feature/one/",
|
||||
},
|
||||
expected: []string{
|
||||
"one",
|
||||
},
|
||||
},
|
||||
{
|
||||
input: []string{
|
||||
"/a/b/c/d",
|
||||
"/a/b/c/e",
|
||||
"/a/b/f/d",
|
||||
"/a/e/c/d",
|
||||
},
|
||||
expected: []string{
|
||||
"b/c/d",
|
||||
"e",
|
||||
"f/d",
|
||||
"e/c/d",
|
||||
},
|
||||
},
|
||||
} {
|
||||
actual := getUniqueNamesFromPaths(scenario.input)
|
||||
assert.EqualValues(t, scenario.expected, actual)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user