Skip to content

chore: add tests for keep_connection feature #26

@ktanaka101

Description

@ktanaka101
          Thanks—code looks good overall! 👍  

Could you add a small regression test for keep_connection before we merge?

Something like:

def test_temp_table_persists_with_keep_connection():
    with tempfile.TemporaryDirectory() as tmpdir:
        cfg = Config(db_path=tmp_path / "test.db", keep_connection=True)
        db = DuckDBDatabase(cfg)

        db.execute_query("CREATE TEMP TABLE t AS SELECT 1 AS v")
        assert db.execute_query("SELECT v FROM t") == [(1,)]

def test_temp_table_does_not_persist_without_keep_connection():
    with tempfile.TemporaryDirectory() as tmpdir:
        cfg = Config(db_path=tmp_path / "test.db", keep_connection=False)
        db = DuckDBDatabase(cfg)

        db.execute_query("CREATE TEMP TABLE t AS SELECT 1 AS v")
        with pytest.raises(duckdb.Error):
            db.execute_query("SELECT v FROM t")

(No need for full fixtures—just something that covers both code paths.)

Originally posted by @ktanaka101 in #24 (review)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions