forked from libgit2/git2go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepository_test.go
42 lines (35 loc) · 986 Bytes
/
repository_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
package git
import (
"testing"
"time"
)
func TestCreateCommitFromIds(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)
loc, err := time.LoadLocation("Europe/Berlin")
checkFatal(t, err)
sig := &Signature{
Name: "Rand Om Hacker",
Email: "[email protected]",
When: time.Date(2013, 03, 06, 14, 30, 0, 0, loc),
}
idx, err := repo.Index()
checkFatal(t, err)
err = idx.AddByPath("README")
checkFatal(t, err)
err = idx.Write()
checkFatal(t, err)
treeId, err := idx.WriteTree()
checkFatal(t, err)
message := "This is a commit\n"
tree, err := repo.LookupTree(treeId)
checkFatal(t, err)
expectedCommitId, err := repo.CreateCommit("HEAD", sig, sig, message, tree)
checkFatal(t, err)
commitId, err := repo.CreateCommitFromIds("", sig, sig, message, treeId)
checkFatal(t, err)
if !expectedCommitId.Equal(commitId) {
t.Errorf("mismatched commit ids, expected %v, got %v", expectedCommitId.String(), commitId.String())
}
}