(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func 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 | } |
nothing calls this directly
no test coverage detected