aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing/object')
-rw-r--r--plumbing/object/change_adaptor_test.go2
-rw-r--r--plumbing/object/change_test.go2
-rw-r--r--plumbing/object/commit_test.go2
-rw-r--r--plumbing/object/difftree_test.go2
-rw-r--r--plumbing/object/file_test.go2
-rw-r--r--plumbing/object/object_test.go2
-rw-r--r--plumbing/object/tag_test.go2
-rw-r--r--plumbing/object/tree.go4
-rw-r--r--plumbing/object/tree_test.go39
9 files changed, 47 insertions, 10 deletions
diff --git a/plumbing/object/change_adaptor_test.go b/plumbing/object/change_adaptor_test.go
index 317c0d6..dd2921d 100644
--- a/plumbing/object/change_adaptor_test.go
+++ b/plumbing/object/change_adaptor_test.go
@@ -10,7 +10,7 @@ import (
"gopkg.in/src-d/go-git.v4/utils/merkletrie"
"gopkg.in/src-d/go-git.v4/utils/merkletrie/noder"
- "github.com/src-d/go-git-fixtures"
+ "gopkg.in/src-d/go-git-fixtures.v3"
. "gopkg.in/check.v1"
)
diff --git a/plumbing/object/change_test.go b/plumbing/object/change_test.go
index ded7ff2..7036fa3 100644
--- a/plumbing/object/change_test.go
+++ b/plumbing/object/change_test.go
@@ -10,8 +10,8 @@ import (
"gopkg.in/src-d/go-git.v4/storage/filesystem"
"gopkg.in/src-d/go-git.v4/utils/merkletrie"
- fixtures "github.com/src-d/go-git-fixtures"
. "gopkg.in/check.v1"
+ "gopkg.in/src-d/go-git-fixtures.v3"
)
type ChangeSuite struct {
diff --git a/plumbing/object/commit_test.go b/plumbing/object/commit_test.go
index 5df71dc..3f178a8 100644
--- a/plumbing/object/commit_test.go
+++ b/plumbing/object/commit_test.go
@@ -6,10 +6,10 @@ import (
"strings"
"time"
- "github.com/src-d/go-git-fixtures"
"gopkg.in/src-d/go-git.v4/plumbing"
. "gopkg.in/check.v1"
+ "gopkg.in/src-d/go-git-fixtures.v3"
"gopkg.in/src-d/go-git.v4/storage/filesystem"
)
diff --git a/plumbing/object/difftree_test.go b/plumbing/object/difftree_test.go
index eb68d4d..c9344b8 100644
--- a/plumbing/object/difftree_test.go
+++ b/plumbing/object/difftree_test.go
@@ -11,7 +11,7 @@ import (
"gopkg.in/src-d/go-git.v4/storage/memory"
"gopkg.in/src-d/go-git.v4/utils/merkletrie"
- "github.com/src-d/go-git-fixtures"
+ "gopkg.in/src-d/go-git-fixtures.v3"
. "gopkg.in/check.v1"
)
diff --git a/plumbing/object/file_test.go b/plumbing/object/file_test.go
index 8c8634d..2288697 100644
--- a/plumbing/object/file_test.go
+++ b/plumbing/object/file_test.go
@@ -8,7 +8,7 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage/filesystem"
- "github.com/src-d/go-git-fixtures"
+ "gopkg.in/src-d/go-git-fixtures.v3"
. "gopkg.in/check.v1"
)
diff --git a/plumbing/object/object_test.go b/plumbing/object/object_test.go
index 6d9028f..2ac5d12 100644
--- a/plumbing/object/object_test.go
+++ b/plumbing/object/object_test.go
@@ -11,7 +11,7 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage/filesystem"
- "github.com/src-d/go-git-fixtures"
+ "gopkg.in/src-d/go-git-fixtures.v3"
. "gopkg.in/check.v1"
)
diff --git a/plumbing/object/tag_test.go b/plumbing/object/tag_test.go
index 9f2d28c..608fe72 100644
--- a/plumbing/object/tag_test.go
+++ b/plumbing/object/tag_test.go
@@ -6,12 +6,12 @@ import (
"strings"
"time"
- "github.com/src-d/go-git-fixtures"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/storage/filesystem"
"gopkg.in/src-d/go-git.v4/storage/memory"
. "gopkg.in/check.v1"
+ "gopkg.in/src-d/go-git-fixtures.v3"
)
type TagSuite struct {
diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go
index 44ac720..2fcd979 100644
--- a/plumbing/object/tree.go
+++ b/plumbing/object/tree.go
@@ -136,9 +136,9 @@ func (t *Tree) dir(baseName string) (*Tree, error) {
}
tree := &Tree{s: t.s}
- tree.Decode(obj)
+ err = tree.Decode(obj)
- return tree, nil
+ return tree, err
}
var errEntryNotFound = errors.New("entry not found")
diff --git a/plumbing/object/tree_test.go b/plumbing/object/tree_test.go
index 796d979..3a687dd 100644
--- a/plumbing/object/tree_test.go
+++ b/plumbing/object/tree_test.go
@@ -1,6 +1,7 @@
package object
import (
+ "errors"
"io"
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -8,8 +9,8 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage/filesystem"
- fixtures "github.com/src-d/go-git-fixtures"
. "gopkg.in/check.v1"
+ "gopkg.in/src-d/go-git-fixtures.v3"
)
type TreeSuite struct {
@@ -113,6 +114,42 @@ func (s *TreeSuite) TestFindEntry(c *C) {
c.Assert(e.Name, Equals, "foo.go")
}
+// Overrides returned plumbing.EncodedObject for given hash.
+// Otherwise, delegates to actual storer to get real object
+type fakeStorer struct {
+ storer.EncodedObjectStorer
+ hash plumbing.Hash
+ fake fakeEncodedObject
+}
+
+func (fs fakeStorer) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (plumbing.EncodedObject, error) {
+ if fs.hash == h {
+ return fs.fake, nil
+ }
+ return fs.EncodedObjectStorer.EncodedObject(t, h)
+}
+
+// Overrides reader of plumbing.EncodedObject to simulate read error
+type fakeEncodedObject struct{ plumbing.EncodedObject }
+
+func (fe fakeEncodedObject) Reader() (io.ReadCloser, error) {
+ return nil, errors.New("Simulate encoded object can't be read")
+}
+
+func (s *TreeSuite) TestDir(c *C) {
+ vendor, err := s.Tree.dir("vendor")
+ c.Assert(err, IsNil)
+
+ t, err := GetTree(s.Tree.s, s.Tree.ID())
+ c.Assert(err, IsNil)
+ o, err := t.s.EncodedObject(plumbing.AnyObject, vendor.ID())
+ c.Assert(err, IsNil)
+
+ t.s = fakeStorer{t.s, vendor.ID(), fakeEncodedObject{o}}
+ _, err = t.dir("vendor")
+ c.Assert(err, NotNil)
+}
+
// This plumbing.EncodedObject implementation has a reader that only returns 6
// bytes at a time, this should simulate the conditions when a read
// returns less bytes than asked, for example when reading a hash which