-
Notifications
You must be signed in to change notification settings - Fork 1
/
id_test.go
48 lines (38 loc) · 1.15 KB
/
id_test.go
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
package main
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRefId(t *testing.T) {
id := refID("refs/heads/master")
assert.Equal(t, "master", id)
}
func TestRefIdRemote(t *testing.T) {
id := refID("refs/remotes/origin/master")
assert.Equal(t, "origin/master", id)
}
func TestRefIdTag(t *testing.T) {
id := refID("refs/tags/0.1")
assert.Equal(t, "0.1", id)
}
func TestObjectId(t *testing.T) {
path := ".git/objects/00/507eabbf76528884df48a1c9fe30434825bf57"
assert.Equal(t, "00507eabbf76528884df48a1c9fe30434825bf57", objectID(path))
}
func TestObjectIdFromNonGitPath(t *testing.T) {
path := "test-repo.git/objects/05/a8da24ba96d54811f7ea93d527968e2dee3c41"
assert.Equal(t, "05a8da24ba96d54811f7ea93d527968e2dee3c41", objectID(path))
}
func TestRefIdWindows(t *testing.T) {
id := refID(filepath.Join("refs", "tags", "0.1"))
assert.Equal(t, "0.1", id)
}
func TestRefIdWindowsRemote(t *testing.T) {
id := refID(filepath.Join("refs", "remotes", "origin", "master"))
assert.Equal(t, "origin/master", id)
}
func TestRefSpecInRefId(t *testing.T) {
path := "ref: refs/heads/master"
assert.Equal(t, "master", refID(path))
}