(t *testing.T)
| 250 | } |
| 251 | |
| 252 | func 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 | |
| 281 | func TestVFSFile_PendingIndexReplacementRemovesStalePages(t *testing.T) { |
| 282 | client := newMockReplicaClient() |
nothing calls this directly
no test coverage detected