mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-14 11:23:09 +02:00
53 lines
767 B
Go
53 lines
767 B
Go
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)
|
|
}
|
|
}
|