Add persistent job run queue
This commit is contained in:
parent
2bd0651478
commit
0b3b1b2731
8 changed files with 1047 additions and 27 deletions
|
|
@ -169,6 +169,40 @@ def test_initialize_database_creates_scheduler_and_execution_indexes(
|
|||
connection.close()
|
||||
|
||||
|
||||
def test_initialize_database_creates_run_queue_indexes(tmp_path: Path) -> None:
|
||||
db_path = tmp_path / "queue-indexes.db"
|
||||
|
||||
initialize_database(db_path)
|
||||
|
||||
connection = sqlite3.connect(db_path)
|
||||
try:
|
||||
indexes = {
|
||||
row[0]: row[1]
|
||||
for row in connection.execute(
|
||||
"""
|
||||
SELECT name, sql
|
||||
FROM sqlite_master
|
||||
WHERE type = 'index'
|
||||
AND name IN (
|
||||
'job_execution_pending_created_at_idx',
|
||||
'job_execution_pending_unique_job_idx'
|
||||
)
|
||||
"""
|
||||
)
|
||||
}
|
||||
assert set(indexes) == {
|
||||
"job_execution_pending_created_at_idx",
|
||||
"job_execution_pending_unique_job_idx",
|
||||
}
|
||||
assert indexes["job_execution_pending_unique_job_idx"] is not None
|
||||
assert (
|
||||
"WHERE running_status = 0"
|
||||
in indexes["job_execution_pending_unique_job_idx"]
|
||||
)
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
|
||||
def test_job_table_allows_exactly_one_job_per_source(tmp_path: Path) -> None:
|
||||
initialize_database(tmp_path / "jobs.db")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue