aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/object_test.go
diff options
context:
space:
mode:
authorkuba-- <kuba@sourced.tech>2018-09-07 09:27:35 +0200
committerkuba-- <kuba@sourced.tech>2018-09-07 13:48:18 +0200
commit8f6b3127c1ff7661113fff2662416c328971a285 (patch)
tree3b127a5edf22140c5a710612cb5e4fcc3879664a /storage/filesystem/object_test.go
parentd3cec13ac0b195bfb897ed038a08b5130ab9969e (diff)
downloadgo-git-8f6b3127c1ff7661113fff2662416c328971a285.tar.gz
Expose Storage cache.
Signed-off-by: kuba-- <kuba@sourced.tech>
Diffstat (limited to 'storage/filesystem/object_test.go')
-rw-r--r--storage/filesystem/object_test.go25
1 files changed, 8 insertions, 17 deletions
diff --git a/storage/filesystem/object_test.go b/storage/filesystem/object_test.go
index 4a921a9..bd4a94b 100644
--- a/storage/filesystem/object_test.go
+++ b/storage/filesystem/object_test.go
@@ -6,6 +6,7 @@ import (
"testing"
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/cache"
"gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit"
. "gopkg.in/check.v1"
@@ -27,8 +28,7 @@ var _ = Suite(&FsSuite{})
func (s *FsSuite) TestGetFromObjectFile(c *C) {
fs := fixtures.ByTag(".git").ByTag("unpacked").One().DotGit()
- o, err := NewObjectStorage(dotgit.New(fs))
- c.Assert(err, IsNil)
+ o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())
expected := plumbing.NewHash("f3dfe29d268303fc6e1bbce268605fc99573406e")
obj, err := o.EncodedObject(plumbing.AnyObject, expected)
@@ -39,8 +39,7 @@ func (s *FsSuite) TestGetFromObjectFile(c *C) {
func (s *FsSuite) TestGetFromPackfile(c *C) {
fixtures.Basic().ByTag(".git").Test(c, func(f *fixtures.Fixture) {
fs := f.DotGit()
- o, err := NewObjectStorage(dotgit.New(fs))
- c.Assert(err, IsNil)
+ o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())
expected := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
obj, err := o.EncodedObject(plumbing.AnyObject, expected)
@@ -53,8 +52,7 @@ func (s *FsSuite) TestGetFromPackfileKeepDescriptors(c *C) {
fixtures.Basic().ByTag(".git").Test(c, func(f *fixtures.Fixture) {
fs := f.DotGit()
dg := dotgit.NewWithOptions(fs, dotgit.Options{KeepDescriptors: true})
- o, err := NewObjectStorageWithOptions(dg, Options{KeepDescriptors: true})
- c.Assert(err, IsNil)
+ o := NewObjectStorageWithOptions(dg, cache.NewObjectLRUDefault(), Options{KeepDescriptors: true})
expected := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
obj, err := o.EncodedObject(plumbing.AnyObject, expected)
@@ -87,8 +85,7 @@ func (s *FsSuite) TestGetFromPackfileKeepDescriptors(c *C) {
func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) {
fs := fixtures.ByTag(".git").ByTag("multi-packfile").One().DotGit()
- o, err := NewObjectStorage(dotgit.New(fs))
- c.Assert(err, IsNil)
+ o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())
expected := plumbing.NewHash("8d45a34641d73851e01d3754320b33bb5be3c4d3")
obj, err := o.getFromPackfile(expected, false)
@@ -104,8 +101,7 @@ func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) {
func (s *FsSuite) TestIter(c *C) {
fixtures.ByTag(".git").ByTag("packfile").Test(c, func(f *fixtures.Fixture) {
fs := f.DotGit()
- o, err := NewObjectStorage(dotgit.New(fs))
- c.Assert(err, IsNil)
+ o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())
iter, err := o.IterEncodedObjects(plumbing.AnyObject)
c.Assert(err, IsNil)
@@ -125,8 +121,7 @@ func (s *FsSuite) TestIterWithType(c *C) {
fixtures.ByTag(".git").Test(c, func(f *fixtures.Fixture) {
for _, t := range objectTypes {
fs := f.DotGit()
- o, err := NewObjectStorage(dotgit.New(fs))
- c.Assert(err, IsNil)
+ o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())
iter, err := o.IterEncodedObjects(t)
c.Assert(err, IsNil)
@@ -308,11 +303,7 @@ func BenchmarkGetObjectFromPackfile(b *testing.B) {
for _, f := range fixtures.Basic() {
b.Run(f.URL, func(b *testing.B) {
fs := f.DotGit()
- o, err := NewObjectStorage(dotgit.New(fs))
- if err != nil {
- b.Fatal(err)
- }
-
+ o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())
for i := 0; i < b.N; i++ {
expected := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
obj, err := o.EncodedObject(plumbing.AnyObject, expected)