MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / TestTx_ListRecoveryWithMixedOperations

Function TestTx_ListRecoveryWithMixedOperations

tx_list_test.go:677–715  ·  view source on GitHub ↗

TestTx_ListRecoveryWithMixedOperations tests recovery after complex operations

(t *testing.T)

Source from the content-addressed store, hash-verified

675
676// TestTx_ListRecoveryWithMixedOperations tests recovery after complex operations
677func TestTx_ListRecoveryWithMixedOperations(t *testing.T) {
678 bucket := "list_bucket"
679 key := testutils.GetTestBytes(0)
680
681 dir := filepath.Join(t.TempDir(), "test_nutsdb_list_recovery_mixed")
682 defer func() { _ = os.RemoveAll(dir) }()
683
684 opts := DefaultOptions
685 opts.Dir = dir
686 db, err := Open(opts)
687 require.NoError(t, err)
688
689 // Create bucket
690 txCreateBucket(t, db, DataStructureList, bucket, nil)
691
692 // RPush 5 elements: [0,1,2,3,4]
693 for i := 0; i < 5; i++ {
694 txPush(t, db, bucket, key, testutils.GetTestBytes(i), false, nil, nil)
695 }
696
697 // LPush 2 elements: [98,99,0,1,2,3,4]
698 txPush(t, db, bucket, key, testutils.GetTestBytes(99), true, nil, nil)
699 txPush(t, db, bucket, key, testutils.GetTestBytes(98), true, nil, nil)
700
701 // Close and reopen
702 err = db.Close()
703 require.NoError(t, err)
704
705 db, err = Open(opts)
706 require.NoError(t, err)
707 defer func() { _ = db.Close() }()
708
709 // Verify recovered state - should have 7 elements
710 txLSize(t, db, bucket, key, 7, nil)
711 txLRange(t, db, bucket, key, 0, -1, 7, [][]byte{
712 testutils.GetTestBytes(98), testutils.GetTestBytes(99), testutils.GetTestBytes(0), testutils.GetTestBytes(1),
713 testutils.GetTestBytes(2), testutils.GetTestBytes(3), testutils.GetTestBytes(4),
714 }, nil)
715}
716
717// TestTx_ListRecoveryMultipleLists tests recovery of multiple lists
718func TestTx_ListRecoveryMultipleLists(t *testing.T) {

Callers

nothing calls this directly

Calls 7

GetTestBytesFunction · 0.92
OpenFunction · 0.85
txCreateBucketFunction · 0.85
txPushFunction · 0.85
txLSizeFunction · 0.85
txLRangeFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected