write tests for file backed db

This commit is contained in:
pedrocarlo 2025-04-02 01:41:53 -03:00
parent 2b4ff48a8b
commit 46eaa52400
3 changed files with 189 additions and 1 deletions

View file

@ -145,10 +145,19 @@ INSERT INTO t VALUES (zeroblob(1024 - 1), zeroblob(1024 - 2), zeroblob(1024 - 3)
def run_test_fn(
self, sql: str, validate: Callable[[str], bool], desc: str = ""
) -> None:
actual = self.shell.execute(sql)
# Print the test that is executing before executing the sql command
# Printing later confuses the user of the code what test has actually failed
if desc:
print(f"Testing: {desc}")
actual = self.shell.execute(sql)
assert validate(actual), f"Test failed\nSQL: {sql}\nActual:\n{repr(actual)}"
def execute_dot(self, dot_command: str) -> None:
self.shell._write_to_pipe(dot_command)
# Enables the use of `with` syntax
def __enter__(self):
return self
def __exit__(self, exception_type, exception_value, exception_traceback):
self.quit()