Skip to content

feat(tests): add automated test suite with 187 bats-core tests - #16

Merged
jpelaez-23blocks merged 5 commits into
mainfrom
feat/automated-test-suite
Aug 7, 2026
Merged

feat(tests): add automated test suite with 187 bats-core tests#16
jpelaez-23blocks merged 5 commits into
mainfrom
feat/automated-test-suite

Conversation

@jpelaez-23blocks

Copy link
Copy Markdown
Contributor

Summary

What's Covered

Unit tests (140): address parsing, message ID format, routing decisions, Ed25519 signing/verification, inbox/sent storage with replay protection, filename sanitization, attachment handling, injection detection (6 categories), trust level determination, content security wrapping

Integration tests (47): send routing (filesystem vs API), fetch URL construction with /v1/ prefix, local send end-to-end, init flow, register flow, inbox/read/delete lifecycle

Regression guards:

Infrastructure

  • tests/test_helper.bash — shared setup with env isolation ($BATS_TEST_TMPDIR), fixture helpers, PATH-based curl mocking
  • package.json — npm devDependencies for bats-core, bats-assert, bats-support
  • run_tests.sh — local test runner (./run_tests.sh unit|integration|all)
  • .github/workflows/tests.yml — CI workflow with 10min timeout

Test plan

  • All 187 tests pass locally (./run_tests.sh all)
  • GitHub Actions CI passes on this PR
  • Verify regression: revert /v1/ prefix → fetch_urls.bats fails
  • Verify regression: remove config.json check → send_routing.bats fails

🤖 Generated with Claude Code

Juan Pelaez and others added 5 commits March 26, 2026 10:14
Adds comprehensive test coverage for the claude-plugin CLI tools using
bats-core, catching the 3 shipped production bugs from PRs #14 and #15:
- Missing /v1/ prefix in fetch URLs (PR #14)
- Millisecond vs seconds timestamps in message IDs (PR #14)
- Filesystem delivery without config.json guard (PR #15)

Includes:
- 140 unit tests covering helpers (address, message ID, routing, signing,
  storage, sanitize, attachments) and security (injection, trust, wrapping)
- 47 integration tests covering send routing, fetch URLs, local send,
  init flow, register flow, and inbox/read/delete lifecycle
- Shared test_helper.bash with env isolation, fixture helpers, curl mocking
- GitHub Actions CI workflow running on every PR and push to main
- npm-based test runner with bats-core, bats-assert, bats-support

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Split CI into parallel ShellCheck + Tests jobs, add path filtering to
skip runs on doc-only changes, add concurrency groups to cancel stale
runs, and tighten timeouts. Fix SC2115 in amp-delete.sh (rm -rf guard).

- Add .shellcheckrc with baseline exclusions (SC2155, SC1090/91, SC2034)
- Replace single-job workflow with parallel lint + test jobs
- Add concurrency group (ci-${{ github.ref }}) with cancel-in-progress
- Add path filters for scripts/, tests/, package files, workflow
- Reduce timeouts: 3min lint, 5min tests (was 10min single job)
- Fix rm -rf to use ${var:?} guard against empty variable expansion
- Add npm lint script for local shellcheck runs

Co-authored-by: Juan Pelaez <juan.pelaez@3metas.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Assigns @jpelaez-23blocks as code owner for all files, with explicit
entries for scripts/, tests/, and .github/ to ensure CI and core code
changes always require owner review.

Co-authored-by: Juan Pelaez <juan.pelaez@3metas.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…ettings

Priority 5 grep-ed the entire .claude/settings.local.json for
CLAUDE_AGENT_NAME=, so a permission allow-rule like
"Bash(CLAUDE_AGENT_NAME=foo amp-send.sh:*)" was scraped and painted
the status bar with a bogus agent identity on detached (non-tmux)
sessions. Read the actual .env.CLAUDE_AGENT_NAME field via jq instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A detached Claude Code session (no --id, no CLAUDE_AGENT_NAME, no tmux)
with many agents hit "Multiple AMP agents found. Use --id" and could not
use AMP at all. Add Priority 3.5: walk up for a .claude/settings.local.json
env.CLAUDE_AGENT_NAME hint, else ask AI Maestro which agent uniquely owns
the cwd (most-specific match, unique only). Makes detached sessions
self-identify so they can send/receive AMP without --id.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jpelaez-23blocks
jpelaez-23blocks merged commit 732d301 into main Aug 7, 2026
1 of 2 checks passed
@jpelaez-23blocks
jpelaez-23blocks deleted the feat/automated-test-suite branch August 7, 2026 21:02
jpelaez-23blocks added a commit that referenced this pull request Aug 18, 2026
…#24)

The `register_flow: registration file has correct permissions` test
failed on the Linux CI runner (surfaced the first time CI ran, after
#16). Root cause is the **test**, not the code: it used `stat -f '%Lp'
|| stat -c '%a'`. On Linux, `stat -f` prints *filesystem* status and
exits 0, so the BSD-first form never reaches the GNU fallback and the
assert compared garbage. The code's `chmod 600` on the registration file
is correct. Reversed to GNU `stat -c` first, BSD `stat -f` fallback —
verified 600 on both macOS and Linux.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Juan Pelaez <juan.pelaez@3metas.com>
Co-authored-by: Claude Opus 4.8 <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