Add testIterator for use in testing
This commit is contained in:
parent
6cb67cdd8c
commit
1181e76ab0
1 changed files with 29 additions and 0 deletions
29
graph/iterator/iterator_test.go
Normal file
29
graph/iterator/iterator_test.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue