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

Function TestIsPrefixScan

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

Source from the content-addressed store, hash-verified

145}
146
147func TestIsPrefixScan(t *testing.T) {
148 bucket := "test_prefix_scan"
149 t.Run("if prefix scanning not found the result return true", func(t *testing.T) {
150 withDefaultDB(t, func(t *testing.T, db *DB) {
151 {
152 txCreateBucket(t, db, DataStructureBTree, bucket, nil)
153 tx, err := db.Begin(true)
154 require.NoError(t, err)
155 for i := 0; i <= 10; i++ {
156 key := []byte("key_" + fmt.Sprintf("%07d", i))
157 val := []byte("val" + fmt.Sprintf("%07d", i))
158 err = tx.Put(bucket, key, val, Persistent)
159 assert.NoError(t, err)
160 }
161 assert.NoError(t, tx.Commit())
162 }
163 {
164 tx, err = db.Begin(false)
165 require.NoError(t, err)
166 prefix := []byte("key_")
167 es, err := tx.PrefixScan(bucket, prefix, 0, 10)
168 assert.NoError(t, tx.Commit())
169 assert.NotEmpty(t, es)
170 got := IsPrefixScan(err)
171 assert.Equal(t, false, got)
172 }
173 {
174 tx, err = db.Begin(false)
175 require.NoError(t, err)
176 prefix := []byte("foo_")
177 es, err := tx.PrefixScan(bucket, prefix, 0, 10)
178 assert.NoError(t, tx.Commit())
179 assert.Empty(t, es)
180 got := IsPrefixScan(err)
181 assert.Equal(t, true, got)
182 }
183 })
184 })
185}
186
187func TestIsPrefixSearchScan(t *testing.T) {
188 regs := "(.+)"

Callers

nothing calls this directly

Calls 8

withDefaultDBFunction · 0.85
txCreateBucketFunction · 0.85
IsPrefixScanFunction · 0.85
RunMethod · 0.80
BeginMethod · 0.80
CommitMethod · 0.80
PrefixScanMethod · 0.65
PutMethod · 0.45

Tested by

no test coverage detected