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

Function TestWriteBatchCancel_UnregistersTransaction

batch_test.go:212–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

210}
211
212func TestWriteBatchCancel_UnregistersTransaction(t *testing.T) {
213 db, err := Open(
214 DefaultOptions,
215 WithDir(t.TempDir()),
216 )
217 require.NoError(t, err)
218 defer func() { require.NoError(t, db.Close()) }()
219
220 wb, err := db.NewWriteBatch()
221 require.NoError(t, err)
222 require.Equal(t, int64(1), db.transactionMgr.GetActiveTxCount(), "write batch should register a tx")
223
224 require.NoError(t, wb.Cancel())
225 require.Equal(t, int64(0), db.transactionMgr.GetActiveTxCount(), "Cancel should unregister the tx")
226
227 // Subsequent Cancel should be a no-op.
228 require.NoError(t, wb.Cancel())
229}
230
231func TestWriteBatchFlush_UnregistersFinalTransaction(t *testing.T) {
232 db, err := Open(

Callers

nothing calls this directly

Calls 6

CancelMethod · 0.95
OpenFunction · 0.85
WithDirFunction · 0.85
NewWriteBatchMethod · 0.80
GetActiveTxCountMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected