MCPcopy
hub / github.com/benbjohnson/litestream / TestVFSFile_AutoVacuumShrinksCommit

Function TestVFSFile_AutoVacuumShrinksCommit

vfs_test.go:252–279  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

250}
251
252func TestVFSFile_AutoVacuumShrinksCommit(t *testing.T) {
253 client := newMockReplicaClient()
254 client.addFixture(t, buildLTXFixtureWithPages(t, 1, 4096, []uint32{1, 2, 3, 4}, 'a'))
255
256 f := NewVFSFile(client, "autovac.db", slog.Default())
257 if err := f.Open(); err != nil {
258 t.Fatalf("open vfs file: %v", err)
259 }
260
261 client.addFixture(t, buildLTXFixtureWithPages(t, 2, 4096, []uint32{1, 2}, 'b'))
262 if err := f.pollReplicaClient(context.Background()); err != nil {
263 t.Fatalf("poll replica: %v", err)
264 }
265
266 size, err := f.FileSize()
267 if err != nil {
268 t.Fatalf("file size: %v", err)
269 }
270 if size != int64(2*4096) {
271 t.Fatalf("unexpected file size after vacuum: got %d want %d", size, 2*4096)
272 }
273
274 buf := make([]byte, 4096)
275 lockOffset := int64(3-1) * 4096
276 if _, err := f.ReadAt(buf, lockOffset); err == nil || !strings.Contains(err.Error(), "page not found") {
277 t.Fatalf("expected missing page after vacuum, got %v", err)
278 }
279}
280
281func TestVFSFile_PendingIndexReplacementRemovesStalePages(t *testing.T) {
282 client := newMockReplicaClient()

Callers

nothing calls this directly

Calls 9

OpenMethod · 0.95
pollReplicaClientMethod · 0.95
FileSizeMethod · 0.95
ReadAtMethod · 0.95
newMockReplicaClientFunction · 0.85
buildLTXFixtureWithPagesFunction · 0.85
NewVFSFileFunction · 0.85
addFixtureMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected