Add testIterator for use in testing

This commit is contained in:
Andrew Dunham 2015-04-14 18:38:37 -07:00
parent 6cb67cdd8c
commit 1181e76ab0

View file

@ -0,0 +1,29 @@
package iterator
import (
"github.com/google/cayley/graph"
)
// A testing iterator that returns the given values for Next() and Err().
type testIterator struct {
*Fixed
NextVal bool
ErrVal error
}
func newTestIterator(next bool, err error) graph.Iterator {
return &testIterator{
Fixed: NewFixed(Identity),
NextVal: next,
ErrVal: err,
}
}
func (it *testIterator) Next() bool {
return it.NextVal
}
func (it *testIterator) Err() error {
return it.ErrVal
}