Skip to content

test: add ReadConfigFile unit tests#71

Draft
toddr-bot wants to merge 3 commits into
mainfrom
koan.toddr.bot/test-readconfig
Draft

test: add ReadConfigFile unit tests#71
toddr-bot wants to merge 3 commits into
mainfrom
koan.toddr.bot/test-readconfig

Conversation

@toddr-bot

@toddr-bot toddr-bot commented May 26, 2026

Copy link
Copy Markdown

What

Add 32 unit tests for ReadConfigFile and its integration with the constructor.

Why

Config file loading was only exercised through slow integration tests (config.t) that spawn real server processes. The ReadConfigFile method has six distinct error paths (missing file, syntax errors, invalid return types) plus complex precedence logic (CLI > config > constructor attrs) — none of which had direct unit coverage.

How

New t/readconfig.t with isolated tests using File::Temp config files and an overridden Fatal (same pattern as privdrop.t). Tests cover:

  • Error paths: missing file, Perl syntax error, scalar/arrayref/undef/empty-string returns
  • Happy paths: valid config, empty hash, attribute merging, override behavior, nested structures (clients array)
  • Constructor integration: --configfile CLI flag, configfile constructor attr, precedence ordering

Testing

All 32 new tests pass. Full suite passes (108 tests, 19 files).

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 209 insertions(+)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

ReadConfigFile was only tested via slow integration tests that spawn
real servers. Add 32 focused unit tests covering error paths (missing
file, syntax errors, invalid return types) and the constructor's
config-file integration (precedence: CLI > config > constructor attrs).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cpm now requires Perl 5.24+, breaking CI on Perl 5.8-5.22.
cpanm supports all Perl versions in the test matrix.
The defined-or operator (//) was introduced in Perl 5.10.
Replace with (defined $x ? $x : '') to support Perl 5.8+.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant