aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Navara <filip.navara@gmail.com>2019-04-24 11:58:17 +0200
committerFilip Navara <filip.navara@gmail.com>2019-04-24 11:58:17 +0200
commit55dd4be4dfe8af030b5652782af2d4c37f51197f (patch)
treeb194df6576ae138b6307557b78d26b111ca2e477
parentf4c1a9140f8b2700d9910d35cbab62b2de1fc857 (diff)
downloadgo-git-55dd4be4dfe8af030b5652782af2d4c37f51197f.tar.gz
Add test for CommitNode.ParentNodes()
Signed-off-by: Filip Navara <filip.navara@gmail.com>
-rw-r--r--plumbing/object/commitnode_test.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/plumbing/object/commitnode_test.go b/plumbing/object/commitnode_test.go
index 883befc..1e5f2d9 100644
--- a/plumbing/object/commitnode_test.go
+++ b/plumbing/object/commitnode_test.go
@@ -53,7 +53,29 @@ func testWalker(c *C, nodeIndex CommitNodeIndex) {
}
}
-func (s *CommitNodeSuite) TestWalkObject(c *C) {
+func testParents(c *C, nodeIndex CommitNodeIndex) {
+ merge3, err := nodeIndex.Get(plumbing.NewHash("6f6c5d2be7852c782be1dd13e36496dd7ad39560"))
+ c.Assert(err, IsNil)
+
+ var parents []CommitNode
+ merge3.ParentNodes().ForEach(func(c CommitNode) error {
+ parents = append(parents, c)
+ return nil
+ })
+
+ c.Assert(parents, HasLen, 3)
+
+ expected := []string{
+ "ce275064ad67d51e99f026084e20827901a8361c",
+ "bb13916df33ed23004c3ce9ed3b8487528e655c1",
+ "a45273fe2d63300e1962a9e26a6b15c276cd7082",
+ }
+ for i, parent := range parents {
+ c.Assert(parent.ID().String(), Equals, expected[i])
+ }
+}
+
+func (s *CommitNodeSuite) TestObjectGraph(c *C) {
f := fixtures.ByTag("commit-graph").One()
storer := filesystem.NewStorage(f.DotGit(), cache.NewObjectLRUDefault())
p := f.Packfile()
@@ -63,9 +85,10 @@ func (s *CommitNodeSuite) TestWalkObject(c *C) {
nodeIndex := NewObjectCommitNodeIndex(storer)
testWalker(c, nodeIndex)
+ testParents(c, nodeIndex)
}
-func (s *CommitNodeSuite) TestWalkCommitGraph(c *C) {
+func (s *CommitNodeSuite) TestCommitGraph(c *C) {
f := fixtures.ByTag("commit-graph").One()
dotgit := f.DotGit()
storer := filesystem.NewStorage(dotgit, cache.NewObjectLRUDefault())
@@ -77,4 +100,5 @@ func (s *CommitNodeSuite) TestWalkCommitGraph(c *C) {
nodeIndex := NewGraphCommitNodeIndex(index, storer)
testWalker(c, nodeIndex)
+ testParents(c, nodeIndex)
}