(t *testing.T)
| 383 | } |
| 384 | |
| 385 | func TestVFSFile_TransactionTracking(t *testing.T) { |
| 386 | client := newWriteTestReplicaClient() |
| 387 | |
| 388 | // Create initial LTX file |
| 389 | pageSize := uint32(4096) |
| 390 | initialPage := make([]byte, pageSize) |
| 391 | createTestLTXFile(t, client, 1, pageSize, 1, map[uint32][]byte{1: initialPage}) |
| 392 | |
| 393 | // Create VFSFile with write support |
| 394 | f := setupWriteableVFSFile(t, client) |
| 395 | |
| 396 | if err := f.Open(); err != nil { |
| 397 | t.Fatal(err) |
| 398 | } |
| 399 | defer f.Close() |
| 400 | |
| 401 | // Acquire RESERVED lock (start transaction) |
| 402 | if err := f.Lock(2); err != nil { // sqlite3vfs.LockReserved = 2 |
| 403 | t.Fatal(err) |
| 404 | } |
| 405 | |
| 406 | if !f.inTransaction { |
| 407 | t.Error("expected inTransaction to be true after RESERVED lock") |
| 408 | } |
| 409 | |
| 410 | // Write data |
| 411 | if _, err := f.WriteAt([]byte("tx data"), 0); err != nil { |
| 412 | t.Fatal(err) |
| 413 | } |
| 414 | |
| 415 | // Sync should be skipped during transaction |
| 416 | if err := f.Sync(0); err != nil { |
| 417 | t.Fatal(err) |
| 418 | } |
| 419 | if len(f.dirty) == 0 { |
| 420 | t.Error("expected dirty pages to remain during transaction") |
| 421 | } |
| 422 | |
| 423 | // Release lock (end transaction) |
| 424 | if err := f.Unlock(1); err != nil { // sqlite3vfs.LockShared = 1 |
| 425 | t.Fatal(err) |
| 426 | } |
| 427 | |
| 428 | if f.inTransaction { |
| 429 | t.Error("expected inTransaction to be false after unlock") |
| 430 | } |
| 431 | |
| 432 | // Now sync should work |
| 433 | if err := f.Sync(0); err != nil { |
| 434 | t.Fatal(err) |
| 435 | } |
| 436 | if len(f.dirty) != 0 { |
| 437 | t.Error("expected dirty pages to be cleared after sync") |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | func TestVFSFile_Truncate(t *testing.T) { |
| 442 | client := newWriteTestReplicaClient() |
nothing calls this directly
no test coverage detected