Skip to content

test(scaffold): cover the pre-commit mockery hook (run-mockery.sh)#131

Merged
devantler merged 1 commit into
mainfrom
claude/test-run-mockery-hook
Jun 26, 2026
Merged

test(scaffold): cover the pre-commit mockery hook (run-mockery.sh)#131
devantler merged 1 commit into
mainfrom
claude/test-run-mockery-hook

Conversation

@devantler

Copy link
Copy Markdown
Contributor

🤖 Generated by the Daily AI Assistant

Problem

.github/scripts/run-mockery.sh is the entry of the pre-commit mockery hook (.pre-commit-config.yaml), but it had no test coverage — while its sibling scripts/rename-placeholders.sh is fully test-paired and CI-gated by validate-scaffold.yaml.

The script exists for one reason: the scaffold ships no interfaces and no mockery config, so the hook must be a guarded no-op that keeps a fresh clone's first commit green, and must fail with a helpful install hint (not a bare command not found) once a config exists but mockery isn't installed. A silent regression here — e.g. "simplifying" it to a bare exec mockery — would make every fresh clone's first commit fail, with nothing to catch it.

Change (behaviour-preserving — test + wiring only)

  • .github/scripts/run-mockery.test.sh — a hermetic test that runs the real script against throwaway working directories under a stripped PATH (so the missing-mockery case is guaranteed, not dependent on the runner's installed tools) and pins all three branches:
    • no .mockery.yml/.mockery.yaml → silent no-op, exit 0;
    • config present, mockery PATH-absent → exit 1 with the go install … hint;
    • config present, mockery present → it is exec'd (verified via a /bin/sh stub + marker).
  • .github/workflows/validate-scaffold.yaml — runs the new test alongside the existing onboarding-script test (same template-repo-only gate; no-ops in generated projects via the github.repository guard).
  • AGENTS.md — Structure + Validation sections synced to list the new test and the broadened gate.

Validation

  • sh .github/scripts/run-mockery.test.shPASS (all three branches).
  • shellcheck .github/scripts/run-mockery.test.sh → clean.
  • actionlint .github/workflows/validate-scaffold.yaml → clean.
  • Mutation check: deleting the no-op guard in run-mockery.sh makes the test FAIL (no-config case exits 1 instead of 0); restoring it passes — confirming the test catches a real regression.

No production/script behaviour changed.

run-mockery.sh is the entry point of the pre-commit `mockery` hook; its job is the guarded no-op that keeps a fresh clone's first commit green until the project adds a mockery config, and a helpful exit-1 (not a bare `command not found`) once a config exists but mockery is not installed. It had no coverage, while its sibling rename-placeholders.sh is fully test-paired and CI-gated.

Add a hermetic run-mockery.test.sh that runs the real script under a stripped PATH and pins all three branches (silent no-op without config; exit 1 + install hint when mockery absent; exec when present), and wire it into the existing template-repo-only validate-scaffold.yaml gate alongside the onboarding-script test. Docs synced in AGENTS.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@devantler devantler marked this pull request as ready for review June 26, 2026 14:39
@devantler devantler requested a review from a team as a code owner June 26, 2026 14:39
@devantler devantler merged commit 86b8787 into main Jun 26, 2026
9 checks passed
@devantler devantler deleted the claude/test-run-mockery-hook branch June 26, 2026 15:19
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