(t *testing.T)
| 286 | } |
| 287 | |
| 288 | func TestIndexDeleteRecord(t *testing.T) { |
| 289 | setupRecords(t, true, false) |
| 290 | defer teardownRecords(t) |
| 291 | |
| 292 | i := setupIndex(testFolder) |
| 293 | if err := i.Load(); err != nil { |
| 294 | t.Fatal(err) |
| 295 | } |
| 296 | |
| 297 | for n := 0; n < testRecords; n++ { |
| 298 | id := uint64(n + 1) |
| 299 | if m := i.Delete(id); m == nil { |
| 300 | t.Fatalf("record with id %d not found", id) |
| 301 | } else if deleted := m.(*pb.Record); deleted.Id != id { |
| 302 | t.Fatalf("should have deleted record with id %d, id is %d instead", id, deleted.Id) |
| 303 | } else if i.Size() != testRecords-int(id) { |
| 304 | t.Fatalf("inconsistent index size of %d", i.Size()) |
| 305 | } else if _, err := os.Stat(i.pathFor(deleted)); err == nil { |
| 306 | t.Fatalf("record %d data file was not deleted", deleted.Id) |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | if i.Size() != 0 { |
| 311 | t.Fatalf("expected empty index, found %d elements instead", i.Size()) |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | func TestIndexDeleteRecordWithInvalidId(t *testing.T) { |
| 316 | setupRecords(t, false, false) |
nothing calls this directly
no test coverage detected