This test ensures we don't end up in deadlock in case of empty writebatch.
(t *testing.T)
| 90 | |
| 91 | // This test ensures we don't end up in deadlock in case of empty writebatch. |
| 92 | func TestEmptyWriteBatch(t *testing.T) { |
| 93 | t.Run("normal mode", func(t *testing.T) { |
| 94 | runBadgerTest(t, nil, func(t *testing.T, db *DB) { |
| 95 | wb := db.NewWriteBatch() |
| 96 | require.NoError(t, wb.Flush()) |
| 97 | wb = db.NewWriteBatch() |
| 98 | require.NoError(t, wb.Flush()) |
| 99 | wb = db.NewWriteBatch() |
| 100 | require.NoError(t, wb.Flush()) |
| 101 | }) |
| 102 | }) |
| 103 | t.Run("managed mode", func(t *testing.T) { |
| 104 | opt := getTestOptions("") |
| 105 | opt.managedTxns = true |
| 106 | runBadgerTest(t, &opt, func(t *testing.T, db *DB) { |
| 107 | t.Run("WriteBatchAt", func(t *testing.T) { |
| 108 | wb := db.NewWriteBatchAt(2) |
| 109 | require.NoError(t, wb.Flush()) |
| 110 | wb = db.NewWriteBatchAt(208) |
| 111 | require.NoError(t, wb.Flush()) |
| 112 | wb = db.NewWriteBatchAt(31) |
| 113 | require.NoError(t, wb.Flush()) |
| 114 | }) |
| 115 | t.Run("ManagedWriteBatch", func(t *testing.T) { |
| 116 | wb := db.NewManagedWriteBatch() |
| 117 | require.NoError(t, wb.Flush()) |
| 118 | wb = db.NewManagedWriteBatch() |
| 119 | require.NoError(t, wb.Flush()) |
| 120 | wb = db.NewManagedWriteBatch() |
| 121 | require.NoError(t, wb.Flush()) |
| 122 | }) |
| 123 | }) |
| 124 | }) |
| 125 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…