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

Function TestIsDBClosed

errors_test.go:119–145  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

117}
118
119func TestIsDBClosed(t *testing.T) {
120 InitOpt("", true)
121 bucket := "test_closed"
122 key := []byte("foo")
123 val := []byte("bar")
124 db, err = Open(opt)
125
126 t.Run("db can be used before closed", func(t *testing.T) {
127 txCreateBucket(t, db, DataStructureBTree, bucket, nil)
128
129 err = db.Update(
130 func(tx *Tx) error {
131 return tx.Put(bucket, key, val, Persistent)
132 })
133 require.NoError(t, err)
134 })
135 assert.NoError(t, db.Close())
136
137 t.Run("db can't be used after closed", func(t *testing.T) {
138 err = db.Update(
139 func(tx *Tx) error {
140 return tx.Put(bucket, key, val, Persistent)
141 })
142 got := IsDBClosed(err)
143 assert.Equal(t, true, got)
144 })
145}
146
147func TestIsPrefixScan(t *testing.T) {
148 bucket := "test_prefix_scan"

Callers

nothing calls this directly

Calls 8

InitOptFunction · 0.85
OpenFunction · 0.85
txCreateBucketFunction · 0.85
IsDBClosedFunction · 0.85
RunMethod · 0.80
UpdateMethod · 0.80
CloseMethod · 0.65
PutMethod · 0.45

Tested by

no test coverage detected