This commit is contained in:
sqm 2026-10-17 18:27:50 +03:00 • committed by GitHub
commit 18a45ca8dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 2 deletions

View file

@ -171,6 +171,7 @@ def test_metadata_yaml():
nolock=False,
open_browser=False,
create=False,
create_wal=False,
ssl_keyfile=None,
ssl_certfile=None,
return_instance=True,
@ -462,6 +463,37 @@ def test_serve_create(tmpdir):
assert db_path.exists()
def test_serve_create_wal(tmpdir):
runner = CliRunner()
db_path = tmpdir / "does_not_exist_yet.db"
assert not db_path.exists()
result = runner.invoke(
cli, [str(db_path), "--create-wal", "--get", "/-/databases.json"]
)
assert result.exit_code == 0, result.output
assert db_path.exists()
# The new database should be in WAL mode
conn = sqlite3.connect(str(db_path))
try:
assert conn.execute("pragma journal_mode").fetchone()[0] == "wal"
finally:
conn.close()
def test_serve_create_does_not_set_wal(tmpdir):
runner = CliRunner()
db_path = tmpdir / "does_not_exist_yet.db"
result = runner.invoke(
cli, [str(db_path), "--create", "--get", "/-/databases.json"]
)
assert result.exit_code == 0, result.output
conn = sqlite3.connect(str(db_path))
try:
assert conn.execute("pragma journal_mode").fetchone()[0] != "wal"
finally:
conn.close()
@pytest.mark.parametrize("argument", ("-c", "--config"))
@pytest.mark.parametrize("format_", ("json", "yaml"))
def test_serve_config(tmpdir, argument, format_):