MCPcopy
hub / github.com/cayleygraph/cayley / TestMaterializeIteratorErrorAbort

Function TestMaterializeIteratorErrorAbort

graph/iterator/materialize_test.go:42–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestMaterializeIteratorErrorAbort(t *testing.T) {
43 ctx := context.TODO()
44 wantErr := errors.New("unique")
45 errIt := newTestIterator(false, wantErr)
46
47 // This tests that we properly return 0 results and the error when the
48 // underlying iterator is larger than our 'abort at' value, and then
49 // returns an error.
50 or := NewOr(
51 newInt64(1, int64(MaterializeLimit+1), true),
52 errIt,
53 )
54
55 mIt := NewMaterialize(or)
56
57 // We should get all the underlying values...
58 for i := 0; i < MaterializeLimit+1; i++ {
59 if !mIt.Next(ctx) {
60 t.Errorf("Materialize iterator returned spurious 'false' on iteration %d", i)
61 return
62 }
63 if mIt.Err() != nil {
64 t.Errorf("Materialize iterator returned non-nil Err on iteration %d", i)
65 return
66 }
67 }
68
69 // ... and then the error value.
70 if mIt.Next(ctx) != false {
71 t.Errorf("Materialize iterator did not pass through underlying 'false'")
72 }
73 if mIt.Err() != wantErr {
74 t.Errorf("Materialize iterator did not pass through underlying Err")
75 }
76}

Callers

nothing calls this directly

Calls 7

newTestIteratorFunction · 0.85
NewOrFunction · 0.85
newInt64Function · 0.85
NewMaterializeFunction · 0.85
NextMethod · 0.65
ErrorfMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected