aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/commitgraph/commitgraph_test.go
diff options
context:
space:
mode:
authorFilip Navara <filip.navara@gmail.com>2019-04-23 14:51:52 +0200
committerFilip Navara <filip.navara@gmail.com>2019-04-24 09:40:06 +0200
commit5b30f0c466090923f4f821f05b94573f1336b633 (patch)
tree4be951b847b61b0766e6969c6624b85e063e3274 /plumbing/format/commitgraph/commitgraph_test.go
parenta306018ece3e448d6ebbce856a7dfe5e484d1a84 (diff)
downloadgo-git-5b30f0c466090923f4f821f05b94573f1336b633.tar.gz
Split Encoder into smaller functions
Signed-off-by: Filip Navara <filip.navara@gmail.com>
Diffstat (limited to 'plumbing/format/commitgraph/commitgraph_test.go')
-rw-r--r--plumbing/format/commitgraph/commitgraph_test.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/plumbing/format/commitgraph/commitgraph_test.go b/plumbing/format/commitgraph/commitgraph_test.go
index 581415c..a8e4557 100644
--- a/plumbing/format/commitgraph/commitgraph_test.go
+++ b/plumbing/format/commitgraph/commitgraph_test.go
@@ -1,10 +1,11 @@
package commitgraph_test
import (
- "testing"
+ "fmt"
"io/ioutil"
"os"
"path"
+ "testing"
"golang.org/x/exp/mmap"
@@ -64,36 +65,37 @@ func testDecodeHelper(c *C, path string) {
c.Assert(len(node.ParentIndexes), Equals, 3)
c.Assert(len(node.ParentHashes), Equals, 3)
c.Assert(node.ParentHashes[0].String(), Equals, "ce275064ad67d51e99f026084e20827901a8361c")
- c.Assert(node.ParentHashes[1].String(), Equals, "bb13916df33ed23004c3ce9ed3b8487528e655c1")
- c.Assert(node.ParentHashes[2].String(), Equals, "a45273fe2d63300e1962a9e26a6b15c276cd7082")
+ c.Assert(node.ParentHashes[1].String(), Equals, "bb13916df33ed23004c3ce9ed3b8487528e655c1")
+ c.Assert(node.ParentHashes[2].String(), Equals, "a45273fe2d63300e1962a9e26a6b15c276cd7082")
// Check all hashes
hashes := index.Hashes()
c.Assert(len(hashes), Equals, 11)
- c.Assert(hashes[0].String(), Equals, "03d2c021ff68954cf3ef0a36825e194a4b98f981")
- c.Assert(hashes[10].String(), Equals, "e713b52d7e13807e87a002e812041f248db3f643")
+ c.Assert(hashes[0].String(), Equals, "03d2c021ff68954cf3ef0a36825e194a4b98f981")
+ c.Assert(hashes[10].String(), Equals, "e713b52d7e13807e87a002e812041f248db3f643")
}
func (s *CommitgraphSuite) TestDecode(c *C) {
fixtures.ByTag("commit-graph").Test(c, func(f *fixtures.Fixture) {
- dotgit := f.DotGit()
+ dotgit := f.DotGit()
testDecodeHelper(c, path.Join(dotgit.Root(), "objects", "info", "commit-graph"))
})
}
func (s *CommitgraphSuite) TestReencode(c *C) {
fixtures.ByTag("commit-graph").Test(c, func(f *fixtures.Fixture) {
- dotgit := f.DotGit()
+ dotgit := f.DotGit()
reader, err := mmap.Open(path.Join(dotgit.Root(), "objects", "info", "commit-graph"))
c.Assert(err, IsNil)
defer reader.Close()
index, err := commitgraph.OpenFileIndex(reader)
- c.Assert(err, IsNil)
+ c.Assert(err, IsNil)
writer, err := ioutil.TempFile(dotgit.Root(), "commit-graph")
c.Assert(err, IsNil)
- tmpName := writer.Name()
+ tmpName := writer.Name()
+ fmt.Printf(tmpName)
defer os.Remove(tmpName)
encoder := commitgraph.NewEncoder(writer)
err = encoder.Encode(index)
@@ -106,12 +108,12 @@ func (s *CommitgraphSuite) TestReencode(c *C) {
func (s *CommitgraphSuite) TestReencodeInMemory(c *C) {
fixtures.ByTag("commit-graph").Test(c, func(f *fixtures.Fixture) {
- dotgit := f.DotGit()
+ dotgit := f.DotGit()
reader, err := mmap.Open(path.Join(dotgit.Root(), "objects", "info", "commit-graph"))
c.Assert(err, IsNil)
index, err := commitgraph.OpenFileIndex(reader)
- c.Assert(err, IsNil)
+ c.Assert(err, IsNil)
memoryIndex := commitgraph.NewMemoryIndex()
for i, hash := range index.Hashes() {
node, err := index.GetNodeByIndex(i)
@@ -123,7 +125,7 @@ func (s *CommitgraphSuite) TestReencodeInMemory(c *C) {
writer, err := ioutil.TempFile(dotgit.Root(), "commit-graph")
c.Assert(err, IsNil)
- tmpName := writer.Name()
+ tmpName := writer.Name()
defer os.Remove(tmpName)
encoder := commitgraph.NewEncoder(writer)
err = encoder.Encode(memoryIndex)