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

Function TestTx_ListRecoveryMultipleLists

tx_list_test.go:718–759  ·  view source on GitHub ↗

TestTx_ListRecoveryMultipleLists tests recovery of multiple lists

(t *testing.T)

Source from the content-addressed store, hash-verified

716
717// TestTx_ListRecoveryMultipleLists tests recovery of multiple lists
718func TestTx_ListRecoveryMultipleLists(t *testing.T) {
719 bucket := "list_bucket"
720
721 dir := filepath.Join(t.TempDir(), "test_nutsdb_list_recovery_multiple")
722 defer func() { _ = os.RemoveAll(dir) }()
723
724 opts := DefaultOptions
725 opts.Dir = dir
726 db, err := Open(opts)
727 require.NoError(t, err)
728
729 // Create bucket
730 txCreateBucket(t, db, DataStructureList, bucket, nil)
731
732 // Create multiple lists
733 for listIdx := 0; listIdx < 3; listIdx++ {
734 key := testutils.GetTestBytes(listIdx)
735 for i := 0; i < 5; i++ {
736 txPush(t, db, bucket, key, testutils.GetTestBytes(listIdx*100+i), false, nil, nil)
737 }
738 }
739
740 // Close and reopen
741 err = db.Close()
742 require.NoError(t, err)
743
744 db, err = Open(opts)
745 require.NoError(t, err)
746 defer func() { _ = db.Close() }()
747
748 // Verify all lists recovered correctly
749 for listIdx := 0; listIdx < 3; listIdx++ {
750 key := testutils.GetTestBytes(listIdx)
751 txLSize(t, db, bucket, key, 5, nil)
752
753 expected := make([][]byte, 5)
754 for i := 0; i < 5; i++ {
755 expected[i] = testutils.GetTestBytes(listIdx*100 + i)
756 }
757 txLRange(t, db, bucket, key, 0, -1, 5, expected, nil)
758 }
759}

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