Fix Err fallout for graph/iterator.And iterator
This commit is contained in:
parent
c156fd6b1b
commit
742277e72e
2 changed files with 25 additions and 1 deletions
|
|
@ -29,6 +29,7 @@ type And struct {
|
|||
primaryIt graph.Iterator
|
||||
checkList []graph.Iterator
|
||||
result graph.Value
|
||||
err error
|
||||
runstats graph.IteratorStats
|
||||
}
|
||||
|
||||
|
|
@ -153,9 +154,16 @@ func (it *And) Next() bool {
|
|||
return graph.NextLogOut(it, curr, true)
|
||||
}
|
||||
}
|
||||
if err := graph.Err(it.primaryIt); err != nil {
|
||||
it.err = err
|
||||
}
|
||||
return graph.NextLogOut(it, nil, false)
|
||||
}
|
||||
|
||||
func (it *And) Err() error {
|
||||
return it.err
|
||||
}
|
||||
|
||||
func (it *And) Result() graph.Value {
|
||||
return it.result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
package iterator
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/google/cayley/graph"
|
||||
|
|
@ -138,5 +139,20 @@ func TestAllIterators(t *testing.T) {
|
|||
if and.Next() {
|
||||
t.Error("Too many values")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestAndIteratorErr(t *testing.T) {
|
||||
retErr := errors.New("unique")
|
||||
allErr := newTestIterator(false, retErr)
|
||||
|
||||
and := NewAnd()
|
||||
and.AddSubIterator(allErr)
|
||||
and.AddSubIterator(NewInt64(1, 5))
|
||||
|
||||
if and.Next() != false {
|
||||
t.Errorf("And iterator did not pass through initial 'false'")
|
||||
}
|
||||
if and.Err() != retErr {
|
||||
t.Errorf("And iterator did not pass through underlying Err")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue