TestTx_ListRecoveryMultipleLists tests recovery of multiple lists
(t *testing.T)
| 716 | |
| 717 | // TestTx_ListRecoveryMultipleLists tests recovery of multiple lists |
| 718 | func 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 | } |
nothing calls this directly
no test coverage detected