Fix Err fallout for graph/iterator.Comparison iterator
This commit is contained in:
parent
bb5fd55e21
commit
40cbbfcc1b
2 changed files with 23 additions and 0 deletions
|
|
@ -51,6 +51,7 @@ type Comparison struct {
|
||||||
val interface{}
|
val interface{}
|
||||||
qs graph.QuadStore
|
qs graph.QuadStore
|
||||||
result graph.Value
|
result graph.Value
|
||||||
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewComparison(sub graph.Iterator, op Operator, val interface{}, qs graph.QuadStore) *Comparison {
|
func NewComparison(sub graph.Iterator, op Operator, val interface{}, qs graph.QuadStore) *Comparison {
|
||||||
|
|
@ -133,9 +134,16 @@ func (it *Comparison) Next() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := graph.Err(it.subIt); err != nil {
|
||||||
|
it.err = err
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (it *Comparison) Err() error {
|
||||||
|
return it.err
|
||||||
|
}
|
||||||
|
|
||||||
// DEPRECATED
|
// DEPRECATED
|
||||||
func (it *Comparison) ResultTree() *graph.ResultTree {
|
func (it *Comparison) ResultTree() *graph.ResultTree {
|
||||||
return graph.NewResultTree(it.Result())
|
return graph.NewResultTree(it.Result())
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
package iterator
|
package iterator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -118,3 +119,17 @@ func TestVCIContains(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestComparisonIteratorErr(t *testing.T) {
|
||||||
|
retErr := errors.New("unique")
|
||||||
|
errIt := newTestIterator(false, retErr)
|
||||||
|
|
||||||
|
vc := NewComparison(errIt, compareLT, int64(2), simpleStore)
|
||||||
|
|
||||||
|
if vc.Next() != false {
|
||||||
|
t.Errorf("Comparison iterator did not pass through initial 'false'")
|
||||||
|
}
|
||||||
|
if vc.Err() != retErr {
|
||||||
|
t.Errorf("Comparison iterator did not pass through underlying Err")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue