Start adding tests, using testament.
FossilOrigin-Name: 6f368f0d303c65000c74f346b7bc39ffca964aff7767c60be2384739e5dc4d72
This commit is contained in:
parent
89e879ca68
commit
1ed442a68a
16 changed files with 200 additions and 44 deletions
10
tests/connection/t_can_create_new_connection.nim
Normal file
10
tests/connection/t_can_create_new_connection.nim
Normal 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
|
||||
|
||||
13
tests/connection/t_can_interrupt_running_query.nim
Normal file
13
tests/connection/t_can_interrupt_running_query.nim
Normal 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()
|
||||
|
||||
12
tests/connection/t_can_set_connection_query_timeout.nim
Normal file
12
tests/connection/t_can_set_connection_query_timeout.nim
Normal 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 )
|
||||
|
||||
6
tests/constants/t_has_a_default_config.nim
Normal file
6
tests/constants/t_has_a_default_config.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# vim: set et sta sw=4 ts=4 :
|
||||
|
||||
import kuzu
|
||||
|
||||
assert typeOf( KUZU_DEFAULT_CONFIG ) is kuzu_system_config
|
||||
|
||||
7
tests/constants/t_has_a_version.nim
Normal file
7
tests/constants/t_has_a_version.nim
Normal 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+$" )
|
||||
|
||||
7
tests/constants/t_knows_its_libversion.nim
Normal file
7
tests/constants/t_knows_its_libversion.nim
Normal 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+$" )
|
||||
|
||||
6
tests/constants/t_knows_its_storage_version.nim
Normal file
6
tests/constants/t_knows_its_storage_version.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# vim: set et sta sw=4 ts=4 :
|
||||
|
||||
import kuzu
|
||||
|
||||
assert KUZU_STORAGE_VERSION >= 36
|
||||
|
||||
7
tests/database/t_can_create_in_memory.nim
Normal file
7
tests/database/t_can_create_in_memory.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# vim: set et sta sw=4 ts=4 :
|
||||
|
||||
import kuzu
|
||||
|
||||
var db = newKuzuDatabase()
|
||||
assert db.path == "(in-memory)"
|
||||
|
||||
17
tests/database/t_can_create_with_custom_config.nim
Normal file
17
tests/database/t_can_create_with_custom_config.nim
Normal 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()
|
||||
|
||||
19
tests/database/t_creates_with_default_config.nim
Normal file
19
tests/database/t_creates_with_default_config.nim
Normal 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()
|
||||
|
||||
20
tests/queries/t_can_execute_a_simple_queries.nim
Normal file
20
tests/queries/t_can_execute_a_simple_queries.nim
Normal 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
|
||||
|
||||
14
tests/queries/t_raises_on_bad_syntax.nim
Normal file
14
tests/queries/t_raises_on_bad_syntax.nim
Normal 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'""" )
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue