Start adding tests, using testament.

FossilOrigin-Name: 6f368f0d303c65000c74f346b7bc39ffca964aff7767c60be2384739e5dc4d72
This commit is contained in:
mahlon 2025-03-18 02:21:06 +00:00
parent 89e879ca68
commit 1ed442a68a
16 changed files with 200 additions and 44 deletions

View file

@ -0,0 +1,10 @@
# vim: set et sta sw=4 ts=4 :
import kuzu
let db = newKuzuDatabase()
assert db.path == "(in-memory)"
assert typeOf( db.connect ) is KuzuConnection

View file

@ -0,0 +1,13 @@
# vim: set et sta sw=4 ts=4 :
import kuzu
let db = newKuzuDatabase()
let conn = db.connect
# FIXME: This test should really perform some
# long running query in a thread, and cancel
# it from elsewhere.
conn.queryInterrupt()

View file

@ -0,0 +1,12 @@
# vim: set et sta sw=4 ts=4 :
import kuzu
let db = newKuzuDatabase()
let conn = db.connect
# There is currently no getter for this, so
# we'll just have to assume a lack of
# exception/error means success.
conn.queryTimeout( 1000 )

View file

@ -0,0 +1,6 @@
# vim: set et sta sw=4 ts=4 :
import kuzu
assert typeOf( KUZU_DEFAULT_CONFIG ) is kuzu_system_config

View file

@ -0,0 +1,7 @@
# vim: set et sta sw=4 ts=4 :
import re
import kuzu
assert KUZU_VERSION.contains( re"^\d+\.\d+\.\d+$" )

View file

@ -0,0 +1,7 @@
# vim: set et sta sw=4 ts=4 :
import re
import kuzu
assert KUZU_LIBVERSION.contains( re"^\d+\.\d+\.\d+$" )

View file

@ -0,0 +1,6 @@
# vim: set et sta sw=4 ts=4 :
import kuzu
assert KUZU_STORAGE_VERSION >= 36

View file

@ -0,0 +1,7 @@
# vim: set et sta sw=4 ts=4 :
import kuzu
var db = newKuzuDatabase()
assert db.path == "(in-memory)"

View file

@ -0,0 +1,17 @@
# vim: set et sta sw=4 ts=4 :
import
std/dirs,
std/paths
import kuzu
const DATABASE_PATH = Path( "tmp/testdb" )
DATABASE_PATH.removeDir()
var db = newKuzuDatabase( $DATABASE_PATH, kuzuConfig( auto_checkpoint=false ) )
assert db.path == "tmp/testdb"
assert db.config.auto_checkpoint == false
DATABASE_PATH.removeDir()

View file

@ -0,0 +1,19 @@
# vim: set et sta sw=4 ts=4 :
import
std/dirs,
std/paths
import kuzu
const DATABASE_PATH = Path( "tmp/testdb" )
DATABASE_PATH.removeDir()
var db = newKuzuDatabase( $DATABASE_PATH )
assert db.path == $DATABASE_PATH
assert db.config == kuzuConfig()
assert db.config.read_only == false
DATABASE_PATH.removeDir()

View file

@ -0,0 +1,20 @@
# vim: set et sta sw=4 ts=4 :
import kuzu
let db = newKuzuDatabase()
let conn = db.connect
var q = conn.query( "CREATE NODE TABLE Doop ( id SERIAL, thing STRING, PRIMARY KEY(id) )" )
assert typeOf( q ) is KuzuQueryResult
for thing in @[ "Camel", "Lampshade", "Delicious Cake" ]:
q = conn.query( "CREATE (d:Doop {thing: '" & thing & "'})" )
assert typeOf( q ) is KuzuQueryResult
q = conn.query( "MATCH (d:Doop) RETURN d.thing" )
assert q.num_columns == 1
assert q.num_tuples == 3
assert q.compile_time > 0
assert q.execution_time > 0

View file

@ -0,0 +1,14 @@
# vim: set et sta sw=4 ts=4 :
import
std/re
import kuzu
let db = newKuzuDatabase()
let conn = db.connect
try:
discard conn.query( "NOPE NOPE NOPE" )
except KuzuQueryException as err:
assert err.msg.contains( re"""Error running query:.*extraneous input 'NOPE'""" )