Perform magic checks on a database file for better error messaging.
This commit is contained in:
parent
6881d15358
commit
72da9341fd
11 changed files with 75 additions and 9 deletions
|
|
@ -4,4 +4,5 @@ import kuzu
|
|||
|
||||
var db = newKuzuDatabase()
|
||||
assert db.path == "(in-memory)"
|
||||
assert db.kind == memory
|
||||
|
||||
|
|
|
|||
23
tests/database/t_checks_for_valid_kuzu_file.nim
Normal file
23
tests/database/t_checks_for_valid_kuzu_file.nim
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# vim: set et sta sw=4 ts=4 :
|
||||
|
||||
import
|
||||
std/files,
|
||||
std/paths,
|
||||
std/re
|
||||
|
||||
import kuzu
|
||||
|
||||
const NOT_A_DATABASE_PATH = Path( "tmp/not-a-db" )
|
||||
|
||||
NOT_A_DATABASE_PATH.removeFile()
|
||||
var fh = NOT_A_DATABASE_PATH.string.open( fmWrite )
|
||||
fh.write( "Hi." )
|
||||
fh.close
|
||||
|
||||
try:
|
||||
discard newKuzuDatabase( $NOT_A_DATABASE_PATH )
|
||||
except KuzuException as err:
|
||||
assert err.msg.contains( re"""Unable to open database: "tmp/not-a-db" Doesn't appear to be a Kuzu file""" )
|
||||
|
||||
NOT_A_DATABASE_PATH.removeFile()
|
||||
|
||||
|
|
@ -12,6 +12,7 @@ DATABASE_PATH.removeFile()
|
|||
var db = newKuzuDatabase( $DATABASE_PATH )
|
||||
|
||||
assert db.path == $DATABASE_PATH
|
||||
assert db.kind == disk
|
||||
assert db.config == kuzuConfig()
|
||||
assert db.config.read_only == false
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue