summaryrefslogtreecommitdiff
path: root/index_test.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2015-05-19 14:33:30 +0200
committerCarlos Martín Nieto <[email protected]>2015-05-19 14:49:05 +0200
commita8ad0d204052d8bd9c4d0093cce62c54afa67188 (patch)
tree0dcd8d089a9e4b03ee3bfb3643314b00e8893359 /index_test.go
parentf7781c0e0004f76833c6be93409320b5c143e0c8 (diff)
Index: Add ReadTree()
Diffstat (limited to 'index_test.go')
-rw-r--r--index_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/index_test.go b/index_test.go
index 647a0b8..a1f0c9c 100644
--- a/index_test.go
+++ b/index_test.go
@@ -22,6 +22,34 @@ func TestCreateRepoAndStage(t *testing.T) {
}
}
+func TestIndexReadTree(t *testing.T) {
+ repo := createTestRepo(t)
+ defer cleanupTestRepo(t, repo)
+
+ _, _ = seedTestRepo(t, repo)
+
+ ref, err := repo.Head()
+ checkFatal(t, err)
+
+ obj, err := ref.Peel(ObjectTree);
+ checkFatal(t, err)
+
+ tree := obj.(*Tree)
+
+ idx, err := NewIndex()
+ checkFatal(t, err)
+
+ err = idx.ReadTree(tree)
+ checkFatal(t, err)
+
+ id, err := idx.WriteTreeTo(repo)
+ checkFatal(t, err)
+
+ if tree.Id().Cmp(id) != 0 {
+ t.Fatalf("Read and written trees are not the same")
+ }
+}
+
func TestIndexWriteTreeTo(t *testing.T) {
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)