mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-18 17:14:20 +01:00
Fix pragma module list tests
This commit is contained in:
@@ -701,7 +701,7 @@ def test_create_virtual_table():
|
|||||||
ext_path = "target/debug/libturso_ext_tests"
|
ext_path = "target/debug/libturso_ext_tests"
|
||||||
|
|
||||||
limbo = TestTursoShell()
|
limbo = TestTursoShell()
|
||||||
limbo.execute_dot(f".load {ext_path}")
|
test_module_list(limbo, ext_path, "kv_store")
|
||||||
|
|
||||||
limbo.run_debug("CREATE VIRTUAL TABLE t1 USING kv_store;")
|
limbo.run_debug("CREATE VIRTUAL TABLE t1 USING kv_store;")
|
||||||
limbo.run_test_fn(
|
limbo.run_test_fn(
|
||||||
@@ -741,8 +741,7 @@ def test_csv():
|
|||||||
# open new empty connection explicitly to test whether we can load an extension
|
# open new empty connection explicitly to test whether we can load an extension
|
||||||
# with brand new connection/uninitialized database.
|
# with brand new connection/uninitialized database.
|
||||||
limbo = TestTursoShell(init_commands="")
|
limbo = TestTursoShell(init_commands="")
|
||||||
ext_path = "./target/debug/liblimbo_csv"
|
test_module_list(limbo, "target/debug/liblimbo_csv", "csv")
|
||||||
limbo.execute_dot(f".load {ext_path}")
|
|
||||||
|
|
||||||
limbo.run_test_fn(
|
limbo.run_test_fn(
|
||||||
"CREATE VIRTUAL TABLE temp.csv USING csv(filename=./testing/test_files/test.csv);",
|
"CREATE VIRTUAL TABLE temp.csv USING csv(filename=./testing/test_files/test.csv);",
|
||||||
@@ -828,6 +827,7 @@ def cleanup():
|
|||||||
def test_tablestats():
|
def test_tablestats():
|
||||||
ext_path = "target/debug/libturso_ext_tests"
|
ext_path = "target/debug/libturso_ext_tests"
|
||||||
limbo = TestTursoShell(use_testing_db=True)
|
limbo = TestTursoShell(use_testing_db=True)
|
||||||
|
test_module_list(limbo, ext_path=ext_path, module_name="tablestats")
|
||||||
limbo.execute_dot("CREATE TABLE people(id INTEGER PRIMARY KEY, name TEXT);")
|
limbo.execute_dot("CREATE TABLE people(id INTEGER PRIMARY KEY, name TEXT);")
|
||||||
limbo.execute_dot("INSERT INTO people(name) VALUES ('Ada'), ('Grace'), ('Linus');")
|
limbo.execute_dot("INSERT INTO people(name) VALUES ('Ada'), ('Grace'), ('Linus');")
|
||||||
|
|
||||||
@@ -845,8 +845,6 @@ def test_tablestats():
|
|||||||
lambda res: res == "1",
|
lambda res: res == "1",
|
||||||
"one logs rowverify logs count",
|
"one logs rowverify logs count",
|
||||||
)
|
)
|
||||||
# load extension
|
|
||||||
limbo.execute_dot(f".load {ext_path}")
|
|
||||||
limbo.execute_dot("CREATE VIRTUAL TABLE stats USING tablestats;")
|
limbo.execute_dot("CREATE VIRTUAL TABLE stats USING tablestats;")
|
||||||
|
|
||||||
def _split(res):
|
def _split(res):
|
||||||
@@ -1071,40 +1069,25 @@ def _test_hidden_columns(exec_name, ext_path):
|
|||||||
|
|
||||||
limbo.quit()
|
limbo.quit()
|
||||||
|
|
||||||
def test_module_list(exec_name=None, ext_path="target/debug/libturso_ext_tests"):
|
|
||||||
|
def test_module_list(turso_shell, ext_path, module_name):
|
||||||
|
"""loads the extension at the provided path and asserts that 'PRAGMA module_list;' displays 'module_name'"""
|
||||||
console.info(f"Running test_module_list for {ext_path}")
|
console.info(f"Running test_module_list for {ext_path}")
|
||||||
|
|
||||||
limbo = TestTursoShell(
|
turso_shell.run_test_fn(
|
||||||
exec_name=exec_name,
|
|
||||||
)
|
|
||||||
limbo.run_test_fn(
|
|
||||||
"PRAGMA module_list;",
|
"PRAGMA module_list;",
|
||||||
lambda res: len(res) > 0,
|
lambda res: "generate_series" in res and module_name not in res,
|
||||||
"lists built in modules",
|
"lists built in modules but doesn't contain the module name yet",
|
||||||
)
|
)
|
||||||
|
|
||||||
limbo.run_test_fn(
|
turso_shell.run_test_fn("PRAGMA module_list;", lambda res: module_name not in res, "does not include module list")
|
||||||
|
turso_shell.execute_dot(f".load {ext_path}")
|
||||||
|
turso_shell.run_test_fn(
|
||||||
"PRAGMA module_list;",
|
"PRAGMA module_list;",
|
||||||
lambda res: "kv_store" not in res,
|
lambda res: module_name in res,
|
||||||
"does not include module list"
|
f"includes {module_name} after loading extension",
|
||||||
)
|
)
|
||||||
|
|
||||||
limbo.execute_dot(f".load {ext_path}")
|
|
||||||
|
|
||||||
limbo.run_test_fn(
|
|
||||||
"PRAGMA module_list;",
|
|
||||||
lambda res: "kv_store" in res,
|
|
||||||
"includes kv_store after loading extension",
|
|
||||||
)
|
|
||||||
|
|
||||||
limbo.run_test_fn(
|
|
||||||
"create virtual table t using kv_store;"
|
|
||||||
"pragma module_list;",
|
|
||||||
lambda res: "kv_store" in res,
|
|
||||||
"includes kv_store after virtual table is created with it"
|
|
||||||
)
|
|
||||||
|
|
||||||
limbo.quit()
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
@@ -1122,7 +1105,6 @@ def main():
|
|||||||
test_csv()
|
test_csv()
|
||||||
test_tablestats()
|
test_tablestats()
|
||||||
test_hidden_columns()
|
test_hidden_columns()
|
||||||
test_module_list()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
console.error(f"Test FAILED: {e}")
|
console.error(f"Test FAILED: {e}")
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|||||||
@@ -325,6 +325,7 @@ do_execsql_test_in_memory_any_error pragma-max-page-count-enforcement-error {
|
|||||||
PRAGMA max_page_count = 1;
|
PRAGMA max_page_count = 1;
|
||||||
CREATE TABLE test (id INTEGER)
|
CREATE TABLE test (id INTEGER)
|
||||||
}
|
}
|
||||||
|
|
||||||
do_execsql_test_regex pragma-module-list-nonempty {
|
do_execsql_test_regex pragma-module-list-nonempty {
|
||||||
SELECT * FROM pragma_module_list;
|
SELECT * FROM pragma_module_list;
|
||||||
} {.+}
|
} {\ngenerate_series\n|^generate_series\n|\ngenerate_series$|^generate_series$}
|
||||||
|
|||||||
Reference in New Issue
Block a user