aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/storage_test.go
diff options
context:
space:
mode:
authorJavi Fontan <jfontan@gmail.com>2018-08-30 15:29:51 +0200
committerJavi Fontan <jfontan@gmail.com>2018-08-30 15:29:51 +0200
commit1e1a7d0623459807d6f1e871492147f971f7540c (patch)
tree8e5b96b84c31c173ceeac106f2b54deead19c1b7 /storage/filesystem/storage_test.go
parent5cc316baa64287c7e56cb7372a5046c30fd955c1 (diff)
downloadgo-git-1e1a7d0623459807d6f1e871492147f971f7540c.tar.gz
git: add Static option to PlainOpen
Also adds Static configuration to Storage and DotGit. This option means that the git repository is not expected to be modified while open and enables some optimizations. Each time a file is accessed the storer tries to open an object file for the requested hash. When this is done for a lot of objects it is expensive. With Static option a list of object files is generated the first time an object is accessed and used to check if exists instead of using system calls. A similar optimization is done for packfiles. Signed-off-by: Javi Fontan <jfontan@gmail.com>
Diffstat (limited to 'storage/filesystem/storage_test.go')
-rw-r--r--storage/filesystem/storage_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/storage/filesystem/storage_test.go b/storage/filesystem/storage_test.go
index 4d9ba6f..d7ebf71 100644
--- a/storage/filesystem/storage_test.go
+++ b/storage/filesystem/storage_test.go
@@ -26,6 +26,10 @@ func (s *StorageSuite) SetUpTest(c *C) {
storage, err := NewStorage(osfs.New(s.dir))
c.Assert(err, IsNil)
+ setUpTest(s, c, storage)
+}
+
+func setUpTest(s *StorageSuite, c *C, storage *Storage) {
// ensure that right interfaces are implemented
var _ storer.EncodedObjectStorer = storage
var _ storer.IndexStorer = storage
@@ -51,3 +55,17 @@ func (s *StorageSuite) TestNewStorageShouldNotAddAnyContentsToDir(c *C) {
c.Assert(err, IsNil)
c.Assert(fis, HasLen, 0)
}
+
+type StorageStaticSuite struct {
+ StorageSuite
+}
+
+var _ = Suite(&StorageStaticSuite{})
+
+func (s *StorageStaticSuite) SetUpTest(c *C) {
+ s.dir = c.MkDir()
+ storage, err := NewStorageWithOptions(osfs.New(s.dir), StorageOptions{Static: true})
+ c.Assert(err, IsNil)
+
+ setUpTest(&s.StorageSuite, c, storage)
+}