test: Add local_con() test fixture for cleaner DuckDB connection management - #1476
Conversation
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
local_con() test fixturelocal_con() test fixture for cleaner DuckDB connection management
|
@copilot: Add ... arguments to pass to |
local_con() test fixture for cleaner DuckDB connection managementlocal_con() test fixture for cleaner DuckDB connection management
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
I've completed the requested changes:
Summary:
Changes committed in 901e686. |
local_con() test fixture for cleaner DuckDB connection managementlocal_con() test fixture for cleaner DuckDB connection management
|
@copilot: Doesn't need to be exported. All files must end with an EOL, update instructions in CLAUDE.md . |
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Addressed both issues:
Changes committed in e543751. |
|
@copilot: Fix test failures. |
…cal_con() Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Fixed test failures caused by redundant Changes in 0da4b48:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
local_con() test fixture for cleaner DuckDB connection managementlocal_con() test fixture for cleaner DuckDB connection management
local_con()test fixture for cleaner DuckDB connection managementlocal_con()instead of manualdbConnect()+on.exit()patterns@exportfromlocal_con()function - internal use onlyon.exit()calls when usinglocal_con()Problem
Previously, every test requiring a DuckDB connection used this repetitive pattern:
This approach has several issues:
shutdown = TRUEparameterSolution
The new
local_con()fixture reduces this to a single line:Key Features
withr::defer_parent()to ensure connections are properly closed withshutdown = TRUEduckdb()arguments via...parameterImplementation
The fixture is implemented as:
Changes Made
R/test-fixtures.Rwith thelocal_con()function and documentation (not exported)tests/testthat/test-fixtures.Rarray,bigint,dbdir,read_only,timezone_out,tz_out_convert,environment_scan, andconfigparameterson.exit()calls that were incorrectly left when migrating tolocal_con()Benefits
on.exit()cleanup codeThe fixture leverages the existing
withrdependency (already in Suggests) and maintains full compatibility with existing code patterns while providing comprehensive coverage across the entire test suite.Fixes #79.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.