MCPcopy
hub / github.com/etcd-io/bbolt / TestDB_BeginRW

Function TestDB_BeginRW

db_test.go:693–703  ·  view source on GitHub ↗

Ensure that a read-write transaction can be retrieved.

(t *testing.T)

Source from the content-addressed store, hash-verified

691
692// Ensure that a read-write transaction can be retrieved.
693func TestDB_BeginRW(t *testing.T) {
694 db := btesting.MustCreateDB(t)
695
696 tx, err := db.Begin(true)
697 require.NoError(t, err)
698 require.NotNil(t, tx, "expected tx")
699 defer func() { require.NoError(t, tx.Commit()) }()
700
701 require.True(t, tx.Writable(), "expected writable tx")
702 require.Same(t, db.DB, tx.DB())
703}
704
705// TestDB_Concurrent_WriteTo checks that issuing WriteTo operations concurrently
706// with commits does not produce corrupted db files. It also verifies that all

Callers

nothing calls this directly

Calls 5

MustCreateDBFunction · 0.92
BeginMethod · 0.80
CommitMethod · 0.80
DBMethod · 0.80
WritableMethod · 0.45

Tested by

no test coverage detected