aboutsummaryrefslogtreecommitdiffstats
path: root/storage/test/storage_suite.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-19 22:05:00 +0200
committerGitHub <noreply@github.com>2017-07-19 22:05:00 +0200
commit2d10f1023e609894174b21bdf8d3738010099335 (patch)
tree929b050b54039af69b4eae6306429feafa9d8268 /storage/test/storage_suite.go
parent8738a04708b91683d5804b4c648c871fdeb87f82 (diff)
parent87888eaab1caa52b6b073f610508e0f65b4141f6 (diff)
downloadgo-git-2d10f1023e609894174b21bdf8d3738010099335.tar.gz
Merge pull request #491 from smola/error-checks
*: add more IO error checks
Diffstat (limited to 'storage/test/storage_suite.go')
-rw-r--r--storage/test/storage_suite.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/storage/test/storage_suite.go b/storage/test/storage_suite.go
index 5a7cf9d..7cb0fe3 100644
--- a/storage/test/storage_suite.go
+++ b/storage/test/storage_suite.go
@@ -13,6 +13,7 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage"
+ "github.com/src-d/go-git-fixtures"
. "gopkg.in/check.v1"
)
@@ -64,6 +65,14 @@ func NewBaseStorageSuite(s Storer) BaseStorageSuite {
}}
}
+func (s *BaseStorageSuite) SetUpTest(c *C) {
+ c.Assert(fixtures.Init(), IsNil)
+}
+
+func (s *BaseStorageSuite) TearDownTest(c *C) {
+ c.Assert(fixtures.Clean(), IsNil)
+}
+
func (s *BaseStorageSuite) TestSetEncodedObjectAndEncodedObject(c *C) {
for _, to := range s.testObjects {
comment := Commentf("failed for type %s", to.Type.String())
@@ -143,6 +152,33 @@ func (s *BaseStorageSuite) TestIterEncodedObjects(c *C) {
}
}
+func (s *BaseStorageSuite) TestPackfileWriter(c *C) {
+ pwr, ok := s.Storer.(storer.PackfileWriter)
+ if !ok {
+ c.Skip("not a storer.PackWriter")
+ }
+
+ pw, err := pwr.PackfileWriter()
+ c.Assert(err, IsNil)
+
+ f := fixtures.Basic().One()
+ _, err = io.Copy(pw, f.Packfile())
+ c.Assert(err, IsNil)
+
+ err = pw.Close()
+ c.Assert(err, IsNil)
+
+ iter, err := s.Storer.IterEncodedObjects(plumbing.AnyObject)
+ c.Assert(err, IsNil)
+ objects := 0
+ err = iter.ForEach(func(plumbing.EncodedObject) error {
+ objects++
+ return nil
+ })
+ c.Assert(err, IsNil)
+ c.Assert(objects, Equals, 31)
+}
+
func (s *BaseStorageSuite) TestObjectStorerTxSetEncodedObjectAndCommit(c *C) {
storer, ok := s.Storer.(storer.Transactioner)
if !ok {