summaryrefslogtreecommitdiff
path: root/object_test.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2014-05-25 09:06:18 +0200
committerCarlos Martín Nieto <[email protected]>2014-05-25 09:12:10 +0200
commit2942e18d056d725aa847d77492a75391a670de5f (patch)
tree56f80569a13584c33731cd2b51bfa363b7a89218 /object_test.go
parentec97cb4473ead2d9111ba4a519f3eb87eb7fdc4f (diff)
Give Object and Reference an Onwer accessor
This reduces the need to carry around a pointer to the repository as well as the objects.
Diffstat (limited to 'object_test.go')
-rw-r--r--object_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/object_test.go b/object_test.go
index 85daf78..f525351 100644
--- a/object_test.go
+++ b/object_test.go
@@ -75,3 +75,29 @@ func TestObjectPoymorphism(t *testing.T) {
t.Fatalf("Failed to parse the right revision")
}
}
+
+func checkOwner(t *testing.T, repo *Repository, obj Object) {
+ owner := obj.Owner()
+ if owner == nil {
+ t.Fatal("bad owner")
+ }
+
+ if owner.ptr != repo.ptr {
+ t.Fatalf("bad owner, got %v expected %v\n", owner.ptr, repo.ptr)
+ }
+}
+
+func TestObjectOwner(t *testing.T) {
+ repo := createTestRepo(t)
+ defer os.RemoveAll(repo.Workdir())
+ commitId, treeId := seedTestRepo(t, repo)
+
+ commit, err := repo.LookupCommit(commitId)
+ checkFatal(t, err)
+
+ tree, err := repo.LookupTree(treeId)
+ checkFatal(t, err)
+
+ checkOwner(t, repo, commit)
+ checkOwner(t, repo, tree)
+}