nim-rocksdb/tests/options/test_dbopts.nim
web3-developer d31b8b8a72
Build dynamic libraries for all platforms using vcpkg. (#61)
* Build dynamic libraries for all platforms using vcpkg.

* Cleanup CI.
2024-07-03 11:34:40 +08:00

54 lines
1.3 KiB
Nim

# Nim-RocksDB
# Copyright 2024 Status Research & Development GmbH
# Licensed under either of
#
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
#
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{.used.}
import unittest2, ../../rocksdb/options/dbopts
suite "DbOptionsRef Tests":
test "Test newDbOptions":
let dbOpts = createDbOptions()
check not dbOpts.cPtr.isNil()
dbOpts.maxOpenFiles = 10
dbOpts.createMissingColumnFamilies = false
check:
dbOpts.maxOpenFiles == 10
not dbOpts.createMissingColumnFamilies
dbOpts.close()
test "Test close":
let dbOpts = defaultDbOptions()
check not dbOpts.isClosed()
dbOpts.close()
check dbOpts.isClosed()
dbOpts.close()
check dbOpts.isClosed()
test "Test auto close enabled":
let
dbOpts = defaultDbOptions()
cache = cacheCreateLRU(1000, autoClose = true)
dbOpts.rowCache = cache
check:
dbOpts.isClosed() == false
cache.isClosed() == false
dbOpts.close()
check:
dbOpts.isClosed() == true
cache.isClosed() == true