(t *testing.T)
| 98 | } |
| 99 | |
| 100 | func TestControlRecord(t *testing.T) { |
| 101 | now := time.Now() |
| 102 | |
| 103 | records := []ControlRecord{ |
| 104 | { |
| 105 | Offset: 1, |
| 106 | Time: now, |
| 107 | Version: 2, |
| 108 | Type: 3, |
| 109 | }, |
| 110 | { |
| 111 | Offset: 2, |
| 112 | Time: now.Add(time.Second), |
| 113 | Version: 4, |
| 114 | Type: 5, |
| 115 | Data: []byte("Hello World!"), |
| 116 | Headers: []Header{ |
| 117 | {Key: "answer", Value: []byte("42")}, |
| 118 | }, |
| 119 | }, |
| 120 | } |
| 121 | |
| 122 | batch := NewControlBatch(records...) |
| 123 | found := make([]ControlRecord, 0, len(records)) |
| 124 | |
| 125 | for { |
| 126 | r, err := batch.ReadControlRecord() |
| 127 | if err != nil { |
| 128 | if !errors.Is(err, io.EOF) { |
| 129 | t.Fatal(err) |
| 130 | } |
| 131 | break |
| 132 | } |
| 133 | found = append(found, *r) |
| 134 | } |
| 135 | |
| 136 | if !reflect.DeepEqual(records, found) { |
| 137 | t.Error("control records mismatch") |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | func assertRecords(t *testing.T, r1, r2 RecordReader) { |
| 142 | t.Helper() |
nothing calls this directly
no test coverage detected