MCPcopy Create free account
hub / github.com/evilsocket/sum / TestLoadRecords

Function TestLoadRecords

storage/records_test.go:53–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func 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
76func TestLoadRecordsWithCorruptedData(t *testing.T) {
77 setupRecords(t, false, true)

Callers

nothing calls this directly

Calls 6

LoadRecordsFunction · 0.85
SizeMethod · 0.80
ForEachMethod · 0.80
setupRecordsFunction · 0.70
teardownRecordsFunction · 0.70
sameRecordFunction · 0.70

Tested by

no test coverage detected