(c *C, fs billy.Filesystem, path string)
| 22 | var _ = Suite(&CommitgraphSuite{}) |
| 23 | |
| 24 | func testDecodeHelper(c *C, fs billy.Filesystem, path string) { |
| 25 | reader, err := fs.Open(path) |
| 26 | c.Assert(err, IsNil) |
| 27 | defer reader.Close() |
| 28 | index, err := commitgraph.OpenFileIndex(reader) |
| 29 | c.Assert(err, IsNil) |
| 30 | |
| 31 | // Root commit |
| 32 | nodeIndex, err := index.GetIndexByHash(plumbing.NewHash("347c91919944a68e9413581a1bc15519550a3afe")) |
| 33 | c.Assert(err, IsNil) |
| 34 | commitData, err := index.GetCommitDataByIndex(nodeIndex) |
| 35 | c.Assert(err, IsNil) |
| 36 | c.Assert(len(commitData.ParentIndexes), Equals, 0) |
| 37 | c.Assert(len(commitData.ParentHashes), Equals, 0) |
| 38 | |
| 39 | // Regular commit |
| 40 | nodeIndex, err = index.GetIndexByHash(plumbing.NewHash("e713b52d7e13807e87a002e812041f248db3f643")) |
| 41 | c.Assert(err, IsNil) |
| 42 | commitData, err = index.GetCommitDataByIndex(nodeIndex) |
| 43 | c.Assert(err, IsNil) |
| 44 | c.Assert(len(commitData.ParentIndexes), Equals, 1) |
| 45 | c.Assert(len(commitData.ParentHashes), Equals, 1) |
| 46 | c.Assert(commitData.ParentHashes[0].String(), Equals, "347c91919944a68e9413581a1bc15519550a3afe") |
| 47 | |
| 48 | // Merge commit |
| 49 | nodeIndex, err = index.GetIndexByHash(plumbing.NewHash("b29328491a0682c259bcce28741eac71f3499f7d")) |
| 50 | c.Assert(err, IsNil) |
| 51 | commitData, err = index.GetCommitDataByIndex(nodeIndex) |
| 52 | c.Assert(err, IsNil) |
| 53 | c.Assert(len(commitData.ParentIndexes), Equals, 2) |
| 54 | c.Assert(len(commitData.ParentHashes), Equals, 2) |
| 55 | c.Assert(commitData.ParentHashes[0].String(), Equals, "e713b52d7e13807e87a002e812041f248db3f643") |
| 56 | c.Assert(commitData.ParentHashes[1].String(), Equals, "03d2c021ff68954cf3ef0a36825e194a4b98f981") |
| 57 | |
| 58 | // Octopus merge commit |
| 59 | nodeIndex, err = index.GetIndexByHash(plumbing.NewHash("6f6c5d2be7852c782be1dd13e36496dd7ad39560")) |
| 60 | c.Assert(err, IsNil) |
| 61 | commitData, err = index.GetCommitDataByIndex(nodeIndex) |
| 62 | c.Assert(err, IsNil) |
| 63 | c.Assert(len(commitData.ParentIndexes), Equals, 3) |
| 64 | c.Assert(len(commitData.ParentHashes), Equals, 3) |
| 65 | c.Assert(commitData.ParentHashes[0].String(), Equals, "ce275064ad67d51e99f026084e20827901a8361c") |
| 66 | c.Assert(commitData.ParentHashes[1].String(), Equals, "bb13916df33ed23004c3ce9ed3b8487528e655c1") |
| 67 | c.Assert(commitData.ParentHashes[2].String(), Equals, "a45273fe2d63300e1962a9e26a6b15c276cd7082") |
| 68 | |
| 69 | // Check all hashes |
| 70 | hashes := index.Hashes() |
| 71 | c.Assert(len(hashes), Equals, 11) |
| 72 | c.Assert(hashes[0].String(), Equals, "03d2c021ff68954cf3ef0a36825e194a4b98f981") |
| 73 | c.Assert(hashes[10].String(), Equals, "e713b52d7e13807e87a002e812041f248db3f643") |
| 74 | } |
| 75 | |
| 76 | func (s *CommitgraphSuite) TestDecode(c *C) { |
| 77 | fixtures.ByTag("commit-graph").Test(c, func(f *fixtures.Fixture) { |
no test coverage detected
searching dependent graphs…