Skip to content

feat: add mock_file_checks_guard() for multi-check scoped mocking#111

Draft
Koan-Bot wants to merge 1 commit into
cpan-authors:mainfrom
Koan-Bot:koan.atoomic/feat-mock-file-checks-guard
Draft

feat: add mock_file_checks_guard() for multi-check scoped mocking#111
Koan-Bot wants to merge 1 commit into
cpan-authors:mainfrom
Koan-Bot:koan.atoomic/feat-mock-file-checks-guard

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

@Koan-Bot Koan-Bot commented May 14, 2026

What

Adds mock_file_checks_guard() — mock multiple specific file checks at once, get one guard back.

Why

Current API has a gap between mock_file_check_guard (single check) and mock_all_file_checks (all checks). Tests that need 2–5 specific checks mocked together require managing multiple guard objects or manual cleanup. This fills that gap with a single call.

How

Pure Perl convenience wrapper: iterates check/CODE pairs, calls mock_file_check for each, returns one Guard object covering all checks. No XS changes.

my $guard = mock_file_checks_guard(
    '-e' => sub { CHECK_IS_TRUE },
    '-f' => sub { CHECK_IS_TRUE },
    '-d' => sub { CHECK_IS_FALSE },
);
# all three unmocked when $guard goes out of scope

Testing

16 new tests covering: basic multi-check setup/teardown, FALLBACK_TO_REAL_OP passthrough, guard cancel, error cases (odd args, empty args, duplicate mock), mixed dash/no-dash syntax. Full test suite passes.

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 151 insertions(+), 1 deletion(-)

Code scan: clean

Tests: passed (0 Tests)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Adds a convenience function that mocks multiple specific file checks
at once and returns a single guard object for automatic cleanup.

Fills the API gap between mock_file_check_guard (single check) and
mock_all_file_checks (all checks) — common in tests that need 2-5
specific checks mocked together.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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