aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-09-08 09:31:20 +0200
committerGitHub <noreply@github.com>2018-09-08 09:31:20 +0200
commit208b3c3c32beaab14ebb7adf162fc136c939e99c (patch)
tree33e2e984150cebe2105d84479538128bfaf2ff93 /repository_test.go
parenta4b12e4161738af6f724776c0c8c55f90542f06f (diff)
parent8f6b3127c1ff7661113fff2662416c328971a285 (diff)
downloadgo-git-208b3c3c32beaab14ebb7adf162fc136c939e99c.tar.gz
Merge pull request #949 from kuba--/custom-cache
Expose Storage cache.
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go30
1 files changed, 11 insertions, 19 deletions
diff --git a/repository_test.go b/repository_test.go
index 261af7a..88071cf 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -15,6 +15,7 @@ import (
"gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/cache"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage"
@@ -51,8 +52,7 @@ func (s *RepositorySuite) TestInitNonStandardDotGit(c *C) {
fs := osfs.New(dir)
dot, _ := fs.Chroot("storage")
- storage, err := filesystem.NewStorage(dot)
- c.Assert(err, IsNil)
+ storage := filesystem.NewStorage(dot, cache.NewObjectLRUDefault())
wt, _ := fs.Chroot("worktree")
r, err := Init(storage, wt)
@@ -78,8 +78,7 @@ func (s *RepositorySuite) TestInitStandardDotGit(c *C) {
fs := osfs.New(dir)
dot, _ := fs.Chroot(".git")
- storage, err := filesystem.NewStorage(dot)
- c.Assert(err, IsNil)
+ storage := filesystem.NewStorage(dot, cache.NewObjectLRUDefault())
r, err := Init(storage, fs)
c.Assert(err, IsNil)
@@ -1058,8 +1057,7 @@ func (s *RepositorySuite) TestPushDepth(c *C) {
func (s *RepositorySuite) TestPushNonExistentRemote(c *C) {
srcFs := fixtures.Basic().One().DotGit()
- sto, err := filesystem.NewStorage(srcFs)
- c.Assert(err, IsNil)
+ sto := filesystem.NewStorage(srcFs, cache.NewObjectLRUDefault())
r, err := Open(sto, srcFs)
c.Assert(err, IsNil)
@@ -1277,8 +1275,7 @@ func (s *RepositorySuite) TestTags(c *C) {
func (s *RepositorySuite) TestBranches(c *C) {
f := fixtures.ByURL("https://github.com/git-fixtures/root-references.git").One()
- sto, err := filesystem.NewStorage(f.DotGit())
- c.Assert(err, IsNil)
+ sto := filesystem.NewStorage(f.DotGit(), cache.NewObjectLRUDefault())
r, err := Open(sto, f.DotGit())
c.Assert(err, IsNil)
@@ -1495,8 +1492,7 @@ func (s *RepositorySuite) TestWorktreeBare(c *C) {
func (s *RepositorySuite) TestResolveRevision(c *C) {
f := fixtures.ByURL("https://github.com/git-fixtures/basic.git").One()
- sto, err := filesystem.NewStorage(f.DotGit())
- c.Assert(err, IsNil)
+ sto := filesystem.NewStorage(f.DotGit(), cache.NewObjectLRUDefault())
r, err := Open(sto, f.DotGit())
c.Assert(err, IsNil)
@@ -1548,9 +1544,9 @@ func (s *RepositorySuite) TestResolveRevisionWithErrors(c *C) {
c.Assert(err, IsNil)
datas := map[string]string{
- "efs/heads/master~": "reference not found",
- "HEAD^3": `Revision invalid : "3" found must be 0, 1 or 2 after "^"`,
- "HEAD^{/whatever}": `No commit message match regexp : "whatever"`,
+ "efs/heads/master~": "reference not found",
+ "HEAD^3": `Revision invalid : "3" found must be 0, 1 or 2 after "^"`,
+ "HEAD^{/whatever}": `No commit message match regexp : "whatever"`,
"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83": "reference not found",
"918c48b83bd081e863dbe1b80f8998f058cd8294": `refname "918c48b83bd081e863dbe1b80f8998f058cd8294" is ambiguous`,
}
@@ -1567,8 +1563,7 @@ func (s *RepositorySuite) testRepackObjects(
srcFs := fixtures.ByTag("unpacked").One().DotGit()
var sto storage.Storer
var err error
- sto, err = filesystem.NewStorage(srcFs)
- c.Assert(err, IsNil)
+ sto = filesystem.NewStorage(srcFs, cache.NewObjectLRUDefault())
los := sto.(storer.LooseObjectStorer)
c.Assert(los, NotNil)
@@ -1733,10 +1728,7 @@ func BenchmarkObjects(b *testing.B) {
b.Run(f.URL, func(b *testing.B) {
fs := f.DotGit()
- storer, err := filesystem.NewStorage(fs)
- if err != nil {
- b.Fatal(err)
- }
+ storer := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
worktree, err := fs.Chroot(filepath.Dir(fs.Root()))
if err != nil {