aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/commitgraph
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2021-05-02 23:33:16 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2021-05-02 23:33:16 +0200
commitc69d5331743e49d3672897cf1c552e5e123d4509 (patch)
treedf503db7e8889cef313641b31808fc7404b400e3 /plumbing/format/commitgraph
parent67d34902b0c41ee5d6d283f4c5b6c2ad7db123fd (diff)
downloadgo-git-c69d5331743e49d3672897cf1c552e5e123d4509.tar.gz
plumbing: format, use os.UserHomeDir()
Diffstat (limited to 'plumbing/format/commitgraph')
-rw-r--r--plumbing/format/commitgraph/commitgraph_test.go24
1 files changed, 13 insertions, 11 deletions
diff --git a/plumbing/format/commitgraph/commitgraph_test.go b/plumbing/format/commitgraph/commitgraph_test.go
index de61ae9..4540ae3 100644
--- a/plumbing/format/commitgraph/commitgraph_test.go
+++ b/plumbing/format/commitgraph/commitgraph_test.go
@@ -1,11 +1,11 @@
package commitgraph_test
import (
- "io/ioutil"
"os"
- "path"
"testing"
+ "github.com/go-git/go-billy/v5"
+ "github.com/go-git/go-billy/v5/util"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/format/commitgraph"
@@ -21,8 +21,8 @@ type CommitgraphSuite struct {
var _ = Suite(&CommitgraphSuite{})
-func testDecodeHelper(c *C, path string) {
- reader, err := os.Open(path)
+func testDecodeHelper(c *C, fs billy.Filesystem, path string) {
+ reader, err := fs.Open(path)
c.Assert(err, IsNil)
defer reader.Close()
index, err := commitgraph.OpenFileIndex(reader)
@@ -76,7 +76,7 @@ func testDecodeHelper(c *C, path string) {
func (s *CommitgraphSuite) TestDecode(c *C) {
fixtures.ByTag("commit-graph").Test(c, func(f *fixtures.Fixture) {
dotgit := f.DotGit()
- testDecodeHelper(c, path.Join(dotgit.Root(), "objects", "info", "commit-graph"))
+ testDecodeHelper(c, dotgit, dotgit.Join("objects", "info", "commit-graph"))
})
}
@@ -84,22 +84,23 @@ func (s *CommitgraphSuite) TestReencode(c *C) {
fixtures.ByTag("commit-graph").Test(c, func(f *fixtures.Fixture) {
dotgit := f.DotGit()
- reader, err := os.Open(path.Join(dotgit.Root(), "objects", "info", "commit-graph"))
+ reader, err := dotgit.Open(dotgit.Join("objects", "info", "commit-graph"))
c.Assert(err, IsNil)
defer reader.Close()
index, err := commitgraph.OpenFileIndex(reader)
c.Assert(err, IsNil)
- writer, err := ioutil.TempFile(dotgit.Root(), "commit-graph")
+ writer, err := util.TempFile(dotgit, "", "commit-graph")
c.Assert(err, IsNil)
tmpName := writer.Name()
defer os.Remove(tmpName)
+
encoder := commitgraph.NewEncoder(writer)
err = encoder.Encode(index)
c.Assert(err, IsNil)
writer.Close()
- testDecodeHelper(c, tmpName)
+ testDecodeHelper(c, dotgit, tmpName)
})
}
@@ -107,7 +108,7 @@ func (s *CommitgraphSuite) TestReencodeInMemory(c *C) {
fixtures.ByTag("commit-graph").Test(c, func(f *fixtures.Fixture) {
dotgit := f.DotGit()
- reader, err := os.Open(path.Join(dotgit.Root(), "objects", "info", "commit-graph"))
+ reader, err := dotgit.Open(dotgit.Join("objects", "info", "commit-graph"))
c.Assert(err, IsNil)
index, err := commitgraph.OpenFileIndex(reader)
c.Assert(err, IsNil)
@@ -119,15 +120,16 @@ func (s *CommitgraphSuite) TestReencodeInMemory(c *C) {
}
reader.Close()
- writer, err := ioutil.TempFile(dotgit.Root(), "commit-graph")
+ writer, err := util.TempFile(dotgit, "", "commit-graph")
c.Assert(err, IsNil)
tmpName := writer.Name()
defer os.Remove(tmpName)
+
encoder := commitgraph.NewEncoder(writer)
err = encoder.Encode(memoryIndex)
c.Assert(err, IsNil)
writer.Close()
- testDecodeHelper(c, tmpName)
+ testDecodeHelper(c, dotgit, tmpName)
})
}