(t *testing.T, ctx context.Context, r *Reader)
| 122 | } |
| 123 | |
| 124 | func testReaderSetSpecialOffsets(t *testing.T, ctx context.Context, r *Reader) { |
| 125 | prepareReader(t, ctx, r, Message{Value: []byte("first")}) |
| 126 | prepareReader(t, ctx, r, makeTestSequence(3)...) |
| 127 | |
| 128 | go func() { |
| 129 | time.Sleep(1 * time.Second) |
| 130 | prepareReader(t, ctx, r, Message{Value: []byte("last")}) |
| 131 | }() |
| 132 | |
| 133 | for _, test := range []struct { |
| 134 | off, final int64 |
| 135 | want string |
| 136 | }{ |
| 137 | {FirstOffset, 1, "first"}, |
| 138 | {LastOffset, 5, "last"}, |
| 139 | } { |
| 140 | offset := test.off |
| 141 | if err := r.SetOffset(offset); err != nil { |
| 142 | t.Error("setting offset", offset, "failed:", err) |
| 143 | } |
| 144 | m, err := r.ReadMessage(ctx) |
| 145 | if err != nil { |
| 146 | t.Error("reading at offset", offset, "failed:", err) |
| 147 | } |
| 148 | if string(m.Value) != test.want { |
| 149 | t.Error("message at offset", offset, "has wrong value:", string(m.Value)) |
| 150 | } |
| 151 | if off := r.Offset(); off != test.final { |
| 152 | t.Errorf("bad final offset: got %d, want %d", off, test.final) |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | func testReaderSetRandomOffset(t *testing.T, ctx context.Context, r *Reader) { |
| 158 | const N = 10 |
nothing calls this directly
no test coverage detected