(t *testing.T)
| 51 | } |
| 52 | |
| 53 | func TestLoadRecords(t *testing.T) { |
| 54 | setupRecords(t, true, false) |
| 55 | defer teardownRecords(t) |
| 56 | |
| 57 | records, err := LoadRecords(testFolder) |
| 58 | if err != nil { |
| 59 | t.Fatal(err) |
| 60 | } else if records == nil { |
| 61 | t.Fatal("expected valid records storage") |
| 62 | } else if records.Size() != testRecords { |
| 63 | t.Fatalf("expected %d records, %d found in %s", testRecords, records.Size(), testFolder) |
| 64 | } |
| 65 | |
| 66 | records.ForEach(func(m proto.Message) error { |
| 67 | r := m.(*pb.Record) |
| 68 | // id was updated while saving the record |
| 69 | if r.Id = testRecord.Id; !sameRecord(*r, testRecord) { |
| 70 | t.Fatalf("records should be the same here") |
| 71 | } |
| 72 | return nil |
| 73 | }) |
| 74 | } |
| 75 | |
| 76 | func TestLoadRecordsWithCorruptedData(t *testing.T) { |
| 77 | setupRecords(t, false, true) |
nothing calls this directly
no test coverage detected