Skip to content

Commit

Permalink
Additional tests for WAL mode
Browse files Browse the repository at this point in the history
This should have been included in 2d2d724

Refs #132
  • Loading branch information
simonw committed Sep 7, 2020
1 parent de10590 commit c449064
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_wal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest
from sqlite_utils import Database
import sqlite3


@pytest.fixture
def db_path_tmpdir(tmpdir):
path = tmpdir / "test.db"
db = Database(str(path))
return db, path, tmpdir


def test_enable_disable_wal(db_path_tmpdir):
db, path, tmpdir = db_path_tmpdir
assert len(tmpdir.listdir()) == 1
assert "delete" == db.journal_mode
assert "test.db-wal" not in [f.basename for f in tmpdir.listdir()]
db.enable_wal()
assert "wal" == db.journal_mode
db["test"].insert({"foo": "bar"})
assert "test.db-wal" in [f.basename for f in tmpdir.listdir()]
db.disable_wal()
assert "delete" == db.journal_mode
assert "test.db-wal" not in [f.basename for f in tmpdir.listdir()]

0 comments on commit c449064

Please sign in to comment.