summaryrefslogtreecommitdiff
path: root/index_test.go
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2019-01-08 02:51:21 +0000
committerlhchavez <[email protected]>2019-01-08 02:51:21 +0000
commit6d67bde74a667dcdd060ef519832e8fd81064a8e (patch)
tree705e564b9dedf0ceced47e6f01012cb9fcb6322f /index_test.go
parent35518c78df9ae727651212512bfaa1a8dae02585 (diff)
parent2609f4c6f25a7da56e2e4960c250ea3dfb53e82b (diff)
Merge remote-tracking branch 'upstream/master' into repository-create_commit_from_ids
Diffstat (limited to 'index_test.go')
-rw-r--r--index_test.go26
1 files changed, 21 insertions, 5 deletions
diff --git a/index_test.go b/index_test.go
index f47dace..43644fa 100644
--- a/index_test.go
+++ b/index_test.go
@@ -3,6 +3,7 @@ package git
import (
"io/ioutil"
"os"
+ "path"
"runtime"
"testing"
)
@@ -59,14 +60,29 @@ func TestIndexWriteTreeTo(t *testing.T) {
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)
- repo2 := createTestRepo(t)
- defer cleanupTestRepo(t, repo2)
+ idx, err := NewIndex()
+ checkFatal(t, err)
- idx, err := repo.Index()
+ odb, err := repo.Odb()
checkFatal(t, err)
- err = idx.AddByPath("README")
+
+ content, err := ioutil.ReadFile(path.Join(repo.Workdir(), "README"))
+ checkFatal(t, err)
+
+ id, err := odb.Write(content, ObjectBlob)
checkFatal(t, err)
- treeId, err := idx.WriteTreeTo(repo2)
+
+ err = idx.Add(&IndexEntry{
+ Mode: FilemodeBlob,
+ Uid: 0,
+ Gid: 0,
+ Size: uint32(len(content)),
+ Id: id,
+ Path: "README",
+ })
+ checkFatal(t, err)
+
+ treeId, err := idx.WriteTreeTo(repo)
checkFatal(t, err)
if treeId.String() != "b7119b11e8ef7a1a5a34d3ac87f5b075228ac81e" {