aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/object_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-09-06 21:54:08 +0200
committerGitHub <noreply@github.com>2018-09-06 21:54:08 +0200
commit174f373cf066afc3e3be35576adf3709b0ee278b (patch)
tree22341a6315f5a0df6f1b0a5821b6c319da28d519 /storage/filesystem/object_test.go
parent2f1583896bcc3c182d8165d6aeeb23c771cc5417 (diff)
parent8176f084d861891d1846a2d46bf669d0d3463ebd (diff)
downloadgo-git-174f373cf066afc3e3be35576adf3709b0ee278b.tar.gz
Merge pull request #942 from jfontan/improvement/maintain-packfiles-open
storage/dotgit: add KeepDescriptors option
Diffstat (limited to 'storage/filesystem/object_test.go')
-rw-r--r--storage/filesystem/object_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/storage/filesystem/object_test.go b/storage/filesystem/object_test.go
index b1408b7..4a921a9 100644
--- a/storage/filesystem/object_test.go
+++ b/storage/filesystem/object_test.go
@@ -2,6 +2,7 @@ package filesystem
import (
"io/ioutil"
+ "os"
"testing"
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -48,6 +49,42 @@ func (s *FsSuite) TestGetFromPackfile(c *C) {
})
}
+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)
+
+ expected := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
+ obj, err := o.EncodedObject(plumbing.AnyObject, expected)
+ c.Assert(err, IsNil)
+ c.Assert(obj.Hash(), Equals, expected)
+
+ packfiles, err := dg.ObjectPacks()
+ c.Assert(err, IsNil)
+
+ pack1, err := dg.ObjectPack(packfiles[0])
+ c.Assert(err, IsNil)
+
+ pack1.Seek(42, os.SEEK_SET)
+
+ err = o.Close()
+ c.Assert(err, IsNil)
+
+ pack2, err := dg.ObjectPack(packfiles[0])
+ c.Assert(err, IsNil)
+
+ offset, err := pack2.Seek(0, os.SEEK_CUR)
+ c.Assert(err, IsNil)
+ c.Assert(offset, Equals, int64(0))
+
+ err = o.Close()
+ c.Assert(err, IsNil)
+
+ })
+}
+
func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) {
fs := fixtures.ByTag(".git").ByTag("multi-packfile").One().DotGit()
o, err := NewObjectStorage(dotgit.New(fs))