Files
turso/antithesis-tests/bank-test/finally_validate.py
Pekka Enberg 419ddf0cfa antithesis-tests: Make test drivers robust when database is locked
If multiple processes access the same database file concurrently, Limbo fails with:

```
LockingError("Failed locking file. File is locked by another process
```

Make test driver robust against that.
2025-06-19 10:14:18 +03:00

32 lines
650 B
Python
Executable File

#!/usr/bin/env -S python3 -u
import limbo
from antithesis.random import get_random
from antithesis.assertions import always
try:
con = limbo.connect("bank_test.db")
except Exception as e:
print(f"Error connecting to database: {e}")
exit(0)
cur = con.cursor()
initial_state = cur.execute(f'''
SELECT * FROM initial_state
''').fetchone()
curr_total = cur.execute(f'''
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]
}
)