-
Notifications
You must be signed in to change notification settings - Fork 0
/
reader_test.go
executable file
·91 lines (64 loc) · 1.39 KB
/
reader_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
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
81
82
83
84
85
86
87
88
89
90
91
package main
import "testing"
func TestReferences(t *testing.T) {
repo := GitRepository{"test-data/samplerepo"}
rs := repo.References()
hs := repo.Heads()
ts := repo.Tags()
if len(rs) != len(hs) + len(ts) {
t.Error("Not enough References found")
}
if len(rs) == 0 {
t.Error("Not enough References found")
}
if len(ts) == 0 {
t.Error("Not enough Tags found")
}
}
func TestHashes(t *testing.T) {
repo := GitRepository{"test-data/samplerepo"}
hs := repo.Hashes()
if hs == nil || len(hs) == 0 {
t.Error("No hashes read.")
}
found := false
for _, h := range(hs) {
if h == "620dae1d8c03c241c6ae27c24e76548dbf5b37a1" {
found = true
break
}
}
if found == false {
t.Error("Unable to find hash 620dae1.")
}
}
func TestObjects(t *testing.T) {
repo := GitRepository{"test-data/samplerepo"}
bs, ts, cs := repo.Objects()
if ts == nil || len(ts) == 0 {
t.Error("No trees read.")
}
if bs == nil || len(bs) == 0 {
t.Error("No blobs read.")
}
if cs == nil || len(cs) == 0 {
t.Error("No commits read.")
}
for _, c := range(cs) {
if c.hash == "" {
t.Errorf("Commit hash was blank.")
}
if c.author == "" {
t.Errorf("Commit author was blank.")
}
if c.committer == "" {
t.Errorf("Commit committer was blank.")
}
if c.date == "" {
t.Errorf("Commit date was blank.")
}
if c.tree == "" {
t.Errorf("Commit tree was blank.")
}
}
}