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

Function TestTx_GetSet

tx_btree_test.go:1348–1376  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1346}
1347
1348func TestTx_GetSet(t *testing.T) {
1349 bucket := "bucket"
1350 val := []byte("value")
1351 newVal := []byte("new_value")
1352
1353 t.Run("match value", func(t *testing.T) {
1354 runNutsDBTest(t, nil, func(t *testing.T, db *DB) {
1355 txCreateBucket(t, db, DataStructureBTree, bucket, nil)
1356 txPut(t, db, bucket, testutils.GetTestBytes(1), val, Persistent, nil, nil)
1357 txGetSet(t, db, bucket, testutils.GetTestBytes(1), newVal, val, nil)
1358 txGet(t, db, bucket, testutils.GetTestBytes(1), newVal, nil)
1359 })
1360 })
1361
1362 t.Run("bucket not exist", func(t *testing.T) {
1363 runNutsDBTest(t, nil, func(t *testing.T, db *DB) {
1364 txGetSet(t, db, bucket, testutils.GetTestBytes(1), newVal, nil, ErrBucketNotExist)
1365 })
1366 })
1367
1368 t.Run("expired test", func(t *testing.T) {
1369 runNutsDBTestWithMockClock(t, nil, func(t *testing.T, db *DB, mc ttl.Clock) {
1370 txCreateBucket(t, db, DataStructureBTree, bucket, nil)
1371 txPut(t, db, bucket, testutils.GetTestBytes(1), val, 1, nil, nil)
1372 mc.AdvanceTime(3 * time.Second)
1373 txGetSet(t, db, bucket, testutils.GetTestBytes(1), newVal, nil, ErrKeyNotFound)
1374 })
1375 })
1376}
1377
1378func TestTx_GetTTLAndPersist(t *testing.T) {
1379 bucket := "bucket1"

Callers

nothing calls this directly

Calls 9

GetTestBytesFunction · 0.92
runNutsDBTestFunction · 0.85
txCreateBucketFunction · 0.85
txPutFunction · 0.85
txGetSetFunction · 0.85
txGetFunction · 0.85
RunMethod · 0.80
AdvanceTimeMethod · 0.65

Tested by

no test coverage detected