Skip to content

Commit 0f3c885

Browse files
committed
Cover concurrent initializer compensation guard
1 parent 1185c3b commit 0f3c885

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

‎tests/test_catalog_lifecycle.py‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sqlite3
33

44
import pytest
5-
from sqlalchemy import Table
5+
from sqlalchemy import MetaData, Table
66

77
import openstatspec
88
import openstatspec.sql.wide as wide
@@ -458,3 +458,27 @@ def test_import_fidelity_reader_excludes_export_operational_events(tmp_path):
458458
"details": {},
459459
},)
460460

461+
def test_stale_initializer_compensation_preserves_concurrent_verified_catalog(
462+
tmp_path,
463+
):
464+
path = tmp_path / "concurrent-init.sqlite"
465+
database = f"sqlite:///{path}"
466+
openstatspec.initialize_catalog(database_url=database)
467+
before = _table_names(path)
468+
metadata = MetaData()
469+
legacy, normative = wide._catalog_layout(metadata)
470+
engine = wide.create_engine(database)
471+
with engine.begin() as connection:
472+
wide._compensate_catalog_initialization(
473+
connection,
474+
metadata=metadata,
475+
before_tables=set(),
476+
before_columns={},
477+
normative=normative,
478+
legacy=legacy,
479+
)
480+
wide.require_verified_catalog(connection)
481+
engine.dispose()
482+
483+
assert _table_names(path) == before
484+

0 commit comments

Comments
 (0)