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

Function TestVFSFile_WriteEnabled

vfs_write_test.go:226–258  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

224}
225
226func TestVFSFile_WriteEnabled(t *testing.T) {
227 client := newWriteTestReplicaClient()
228
229 // Create initial LTX file with page 1
230 pageSize := uint32(4096)
231 initialPage := make([]byte, pageSize)
232 copy(initialPage, "initial data")
233 createTestLTXFile(t, client, 1, pageSize, 1, map[uint32][]byte{1: initialPage})
234
235 // Create VFSFile directly with write enabled
236 tmpDir := t.TempDir()
237 bufferPath := tmpDir + "/write-buffer"
238
239 logger := slog.Default()
240 f := NewVFSFile(client, "test.db", logger)
241 f.writeEnabled = true
242 f.dirty = make(map[uint32]int64)
243 f.syncInterval = 0
244 f.bufferPath = bufferPath
245
246 if err := f.Open(); err != nil {
247 t.Fatal(err)
248 }
249 defer f.Close()
250
251 if !f.writeEnabled {
252 t.Error("expected writeEnabled to be true")
253 }
254
255 if f.dirty == nil {
256 t.Error("expected dirty map to be initialized")
257 }
258}
259
260func TestVFSFile_WriteAt(t *testing.T) {
261 client := newWriteTestReplicaClient()

Callers

nothing calls this directly

Calls 6

OpenMethod · 0.95
CloseMethod · 0.95
NewVFSFileFunction · 0.85
createTestLTXFileFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected