summaryrefslogtreecommitdiffstats
path: root/pkg/commands/git_commands/worktree_loader_test.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-16 13:43:20 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-30 18:35:22 +1000
commitc713d550c0a215408969838009865b6b906c7576 (patch)
tree51135aacf7384a69fdc4a3e4a160e75d9df0e8e2 /pkg/commands/git_commands/worktree_loader_test.go
parentd19d89ea9d99015ff4ea45027f0c56047256e7ea (diff)
Improve name handling
Diffstat (limited to 'pkg/commands/git_commands/worktree_loader_test.go')
-rw-r--r--pkg/commands/git_commands/worktree_loader_test.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/pkg/commands/git_commands/worktree_loader_test.go b/pkg/commands/git_commands/worktree_loader_test.go
new file mode 100644
index 000000000..cf3d2a906
--- /dev/null
+++ b/pkg/commands/git_commands/worktree_loader_test.go
@@ -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)
+ }
+}