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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
package name_test
import (
"testing"
"lindenii.org/go/furgit/ref/name"
)
func TestIsPseudo(t *testing.T) {
t.Parallel()
tests := []struct {
name string
want bool
}{
{name: "FETCH_HEAD", want: true},
{name: "MERGE_HEAD", want: true},
{name: "HEAD", want: false},
{name: "AUTO_MERGE", want: false},
}
for _, tt := range tests {
if got := name.IsPseudo(tt.name); got != tt.want {
t.Fatalf("IsPseudo(%q) = %v, want %v", tt.name, got, tt.want)
}
}
}
func TestIsRootSyntax(t *testing.T) {
t.Parallel()
tests := []struct {
name string
want bool
}{
{name: "", want: true},
{name: "HEAD", want: true},
{name: "AUTO_MERGE", want: true},
{name: "BISECT-EXPECTED_REV", want: true},
{name: "refs/heads/main", want: false},
{name: "Head", want: false},
{name: "HEAD1", want: false},
}
for _, tt := range tests {
if got := name.IsRootSyntax(tt.name); got != tt.want {
t.Fatalf("IsRootSyntax(%q) = %v, want %v", tt.name, got, tt.want)
}
}
}
func TestIsRoot(t *testing.T) {
t.Parallel()
tests := []struct {
name string
want bool
}{
{name: "HEAD", want: true},
{name: "ORIG_HEAD", want: true},
{name: "BOGUS_HEAD", want: true},
{name: "CHERRY_PICK_HEAD", want: true},
{name: "REVERT_HEAD", want: true},
{name: "AUTO_MERGE", want: true},
{name: "BISECT_EXPECTED_REV", want: true},
{name: "NOTES_MERGE_PARTIAL", want: true},
{name: "NOTES_MERGE_REF", want: true},
{name: "MERGE_AUTOSTASH", want: true},
{name: "FETCH_HEAD", want: false},
{name: "MERGE_HEAD", want: false},
{name: "Head", want: false},
{name: "refs/heads/main", want: false},
}
for _, tt := range tests {
if got := name.IsRoot(tt.name); got != tt.want {
t.Fatalf("IsRoot(%q) = %v, want %v", tt.name, got, tt.want)
}
}
}
|