diff options
author | Antonio Jesus Navarro Perez <antonio@sourced.tech> | 2017-02-23 11:54:13 +0100 |
---|---|---|
committer | Antonio Jesus Navarro Perez <antonio@sourced.tech> | 2017-02-23 11:54:13 +0100 |
commit | 3a34ab97f6a382f1b28c3cfb49b3725c60b33956 (patch) | |
tree | 1484396f46e7bff7ac691378f12ee664dfcceed3 /plumbing/storer/reference_test.go | |
parent | b5da4e98571b02dc106de4f9b2cb2a298489f1b1 (diff) | |
download | go-git-3a34ab97f6a382f1b28c3cfb49b3725c60b33956.tar.gz |
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"), |