Skip to content

Commit

Permalink
Improve readonly Txn tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wojas committed Dec 7, 2023
1 parent 9e9ad32 commit d6e8388
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lmdb/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,9 @@ func TestTxn_Reset_readonly_C_free(t *testing.T) {

// Since this is a readonly transaction, the global Env key/val cannot be
// reused and new C memory must be allocated.
if txn.key == env.ckey || txn.val == env.cval {
t.Error("env.ckey and cval must not be used in a readonly Txn")
}
if txn.cbuf == nil {
t.Error("cbuf expected to not be nil when opening a readonly Txn")
}
Expand All @@ -951,6 +954,18 @@ func TestTxn_Reset_readonly_C_free(t *testing.T) {
txn.Reset()
if txn.cbuf == nil {
t.Error("cbuf must not be nil after Reset")
return
}

// Renew must not free the buffer
err = txn.Renew()
if err != nil {
t.Error(err)
return
}
if txn.cbuf == nil {
t.Error("cbuf must not be nil after Reset")
return
}

// Abort must free the buffer
Expand Down

0 comments on commit d6e8388

Please sign in to comment.