(t *testing.T, startEarly, oneBatch bool, startKey, endKey []byte)
| 329 | } |
| 330 | |
| 331 | func testIteratorSeekTo(t *testing.T, startEarly, oneBatch bool, |
| 332 | startKey, endKey []byte) { |
| 333 | m, _ := NewCollection(CollectionOptions{}) |
| 334 | |
| 335 | if startEarly { |
| 336 | m.Start() |
| 337 | } |
| 338 | |
| 339 | if oneBatch { |
| 340 | // Insert 1, 3, 5, 7, 9 |
| 341 | batch, _ := m.NewBatch(0, 0) |
| 342 | for i := 1; i <= 9; i += 2 { |
| 343 | x := []byte(fmt.Sprintf("%d", i)) |
| 344 | batch.Set(x, x) |
| 345 | } |
| 346 | m.ExecuteBatch(batch, WriteOptions{}) |
| 347 | batch.Close() |
| 348 | } else { |
| 349 | // Insert 1, 3, 5 |
| 350 | batch, _ := m.NewBatch(0, 0) |
| 351 | for i := 1; i <= 5; i += 2 { |
| 352 | x := []byte(fmt.Sprintf("%d", i)) |
| 353 | batch.Set(x, x) |
| 354 | } |
| 355 | m.ExecuteBatch(batch, WriteOptions{}) |
| 356 | batch.Close() |
| 357 | |
| 358 | // Insert 7, 9 |
| 359 | batch, _ = m.NewBatch(0, 0) |
| 360 | for i := 7; i <= 9; i += 2 { |
| 361 | x := []byte(fmt.Sprintf("%d", i)) |
| 362 | batch.Set(x, x) |
| 363 | } |
| 364 | m.ExecuteBatch(batch, WriteOptions{}) |
| 365 | batch.Close() |
| 366 | } |
| 367 | |
| 368 | ss, err := m.Snapshot() |
| 369 | if err != nil { |
| 370 | t.Errorf("expected no snapshot err, got: %v", err) |
| 371 | } |
| 372 | |
| 373 | itr, err := ss.StartIterator(nil, nil, IteratorOptions{}) |
| 374 | if err != nil { |
| 375 | t.Errorf("expected no itr err, got: %v", err) |
| 376 | } |
| 377 | |
| 378 | err = itr.SeekTo([]byte("0")) |
| 379 | if err == ErrIteratorDone { |
| 380 | t.Errorf("expected done, got: %v", err) |
| 381 | } |
| 382 | |
| 383 | gotk, _, err := itr.Current() |
| 384 | if err != nil { |
| 385 | t.Errorf("expected no Current err, got: %v", err) |
| 386 | } |
| 387 | |
| 388 | expectedk := "1" |
no test coverage detected
searching dependent graphs…