-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrepo_case_test.go
More file actions
36 lines (30 loc) · 1.17 KB
/
repo_case_test.go
File metadata and controls
36 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cmd
import "testing"
func TestFindWorktreeByBranchCaseInsensitiveFallback(t *testing.T) {
entries := []worktreeListEntry{
{Path: "/worktrees/repo/Feature/make-it-work", Branch: "Feature/make-it-work"},
}
if got, ok := findWorktreeByBranch(entries, "feature/make-it-work", false); ok || got != "" {
t.Fatalf("case-sensitive lookup = (%q, %v), want no match", got, ok)
}
got, ok := findWorktreeByBranch(entries, "feature/make-it-work", true)
if !ok {
t.Fatal("case-insensitive lookup did not find worktree")
}
if want := "/worktrees/repo/Feature/make-it-work"; got != want {
t.Fatalf("case-insensitive lookup path = %q, want %q", got, want)
}
}
func TestFindWorktreeByBranchExactMatchWins(t *testing.T) {
entries := []worktreeListEntry{
{Path: "/worktrees/repo/Feature/make-it-work", Branch: "Feature/make-it-work"},
{Path: "/worktrees/repo/feature/make-it-work", Branch: "feature/make-it-work"},
}
got, ok := findWorktreeByBranch(entries, "feature/make-it-work", true)
if !ok {
t.Fatal("lookup did not find exact worktree")
}
if want := "/worktrees/repo/feature/make-it-work"; got != want {
t.Fatalf("lookup path = %q, want exact path %q", got, want)
}
}