This repository was archived by the owner on Sep 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ func (iter *ReferenceSliceIter) ForEach(cb func(*plumbing.Reference) error) erro
70
70
return nil
71
71
}
72
72
73
- return nil
73
+ return err
74
74
}
75
75
}
76
76
Original file line number Diff line number Diff line change 1
1
package storer
2
2
3
3
import (
4
+ "errors"
4
5
"io"
5
6
6
7
. "gopkg.in/check.v1"
@@ -48,6 +49,29 @@ func (s *ReferenceSuite) TestReferenceSliceIterForEach(c *C) {
48
49
c .Assert (count , Equals , 2 )
49
50
}
50
51
52
+ func (s * ReferenceSuite ) TestReferenceSliceIterForEachError (c * C ) {
53
+ slice := []* plumbing.Reference {
54
+ plumbing .NewReferenceFromStrings ("foo" , "foo" ),
55
+ plumbing .NewReferenceFromStrings ("bar" , "bar" ),
56
+ }
57
+
58
+ i := NewReferenceSliceIter (slice )
59
+ var count int
60
+ exampleErr := errors .New ("SOME ERROR" )
61
+ err := i .ForEach (func (r * plumbing.Reference ) error {
62
+ c .Assert (r == slice [count ], Equals , true )
63
+ count ++
64
+ if count == 2 {
65
+ return exampleErr
66
+ }
67
+
68
+ return nil
69
+ })
70
+
71
+ c .Assert (err , Equals , exampleErr )
72
+ c .Assert (count , Equals , 2 )
73
+ }
74
+
51
75
func (s * ReferenceSuite ) TestReferenceSliceIterForEachStop (c * C ) {
52
76
slice := []* plumbing.Reference {
53
77
plumbing .NewReferenceFromStrings ("foo" , "foo" ),
You can’t perform that action at this time.
0 commit comments