diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-24 09:45:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-24 09:45:57 +0100 |
commit | ee3d4c180ce664a4639ecf36d45a47ee1f8b6ee0 (patch) | |
tree | f30330cb0b87a7ae1f45b8a4f4585ae3d8c9ff2f /plumbing/storer/reference_test.go | |
parent | 294d6f4e6f1b60eb0f53515c1fb64b86db21d241 (diff) | |
parent | 3a34ab97f6a382f1b28c3cfb49b3725c60b33956 (diff) | |
download | go-git-ee3d4c180ce664a4639ecf36d45a47ee1f8b6ee0.tar.gz |
Merge pull request #286 from ajnavarro/fix/reference-iterator
plumbing/storer: referenceIterator now returns the error if any
Diffstat (limited to 'plumbing/storer/reference_test.go')
-rw-r--r-- | plumbing/storer/reference_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/plumbing/storer/reference_test.go b/plumbing/storer/reference_test.go index f698820..ff7bd68 100644 --- a/plumbing/storer/reference_test.go +++ b/plumbing/storer/reference_test.go @@ -1,6 +1,7 @@ package storer import ( + "errors" "io" . "gopkg.in/check.v1" @@ -48,6 +49,29 @@ func (s *ReferenceSuite) TestReferenceSliceIterForEach(c *C) { c.Assert(count, Equals, 2) } +func (s *ReferenceSuite) TestReferenceSliceIterForEachError(c *C) { + slice := []*plumbing.Reference{ + plumbing.NewReferenceFromStrings("foo", "foo"), + plumbing.NewReferenceFromStrings("bar", "bar"), + } + + i := NewReferenceSliceIter(slice) + var count int + exampleErr := errors.New("SOME ERROR") + err := i.ForEach(func(r *plumbing.Reference) error { + c.Assert(r == slice[count], Equals, true) + count++ + if count == 2 { + return exampleErr + } + + return nil + }) + + c.Assert(err, Equals, exampleErr) + c.Assert(count, Equals, 2) +} + func (s *ReferenceSuite) TestReferenceSliceIterForEachStop(c *C) { slice := []*plumbing.Reference{ plumbing.NewReferenceFromStrings("foo", "foo"), |