MCPcopy
hub / github.com/dgraph-io/badger / TestEmptyWriteBatch

Function TestEmptyWriteBatch

batch_test.go:92–125  ·  view source on GitHub ↗

This test ensures we don't end up in deadlock in case of empty writebatch.

(t *testing.T)

Source from the content-addressed store, hash-verified

90
91// This test ensures we don't end up in deadlock in case of empty writebatch.
92func 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}

Callers

nothing calls this directly

Calls 6

runBadgerTestFunction · 0.85
getTestOptionsFunction · 0.85
NewWriteBatchMethod · 0.80
NewWriteBatchAtMethod · 0.80
NewManagedWriteBatchMethod · 0.80
FlushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…