Files
turso/antithesis-tests/bank-test/finally_validate.py
2025-06-27 11:27:08 +03:00

27 lines
584 B
Python
Executable File

#!/usr/bin/env -S python3 -u
import turso
from antithesis.assertions import always
try:
con = turso.connect("bank_test.db")
except Exception as e:
print(f"Error connecting to database: {e}")
exit(0)
cur = con.cursor()
initial_state = cur.execute("""
SELECT * FROM initial_state
""").fetchone()
curr_total = cur.execute("""
SELECT SUM(balance) AS total FROM accounts;
""").fetchone()
always(
initial_state[1] == curr_total[0],
"[Finally] Initial balance always equals current balance",
{"init_bal": initial_state[1], "curr_bal": curr_total[0]},
)