Skip to content

test(setup): cover the attribution gate in configure_claude_settings - #29

Merged
rlorenzo merged 1 commit into
mainfrom
test/setup-attribution-settings
Aug 30, 2026
Merged

test(setup): cover the attribution gate in configure_claude_settings#29
rlorenzo merged 1 commit into
mainfrom
test/setup-attribution-settings

Conversation

@rlorenzo

Copy link
Copy Markdown
Owner

What

Adds test/setup-settings.bats, eight tests over the attribution handling in configure_claude_settings.

Why

The attribution block landed in 0e18d88 with no test behind it. The write is a one line jq merge, but the gate in front of it is not: it has to offer the change to a config that has never seen it, migrate one written before sessionUrl existed, and stay silent on a config where the user has chosen their own attribution.

The never-overwrite cases matter most. A run that clobbers "sessionUrl": true, or a custom commit trailer, silently reverses a deliberate decision, and the only evidence would be the next commit.

Coverage

Existing config Expected
no file, or no attribution key offered, writes all three keys
{"commit":"","pr":""} (pre-sessionUrl) offered, sessionUrl added
all three already set not offered
"sessionUrl": true not offered, left as is
"commit": "Made by Claude" not offered, left as is
declined at the prompt file untouched

Plus a check that the result is valid JSON and unrelated keys survive.

How it runs the real code

./setup has no main guard, so sourcing it whole would run the installer. Everything above the argument parsing marker is constants and function definitions, so the helper sources just that prefix and calls configure_claude_settings against the isolated HOME that test_helper already sets up. That exercises the shipped function rather than a copy of its jq.

Verification

  • Full suite green: 178 tests, up from 170.
  • Mutation checked: dropping "sessionUrl": false from the write in setup fails three of the new tests.
  • shellcheck clean.
  • setup itself is unchanged; this PR is tests only.

The attribution block landed in 0e18d88 with no test behind it. The write
itself is a one line jq merge, but the gate in front of it is not: it has to
offer the change to a config that has never seen it, migrate one written
before sessionUrl existed, and stay silent on a config where the user has
chosen their own attribution. Nothing pinned any of that.

The never-overwrite cases are the ones worth locking down. A run that clobbers
"sessionUrl": true, or a custom commit trailer, silently reverses a decision
the user made on purpose, and the only evidence would be the next commit.

./setup has no main guard, so sourcing it whole runs the installer.
Everything above the argument parsing marker is constants and function
definitions, so the helper sources just that prefix and calls
configure_claude_settings against the isolated HOME that test_helper already
sets up. That runs the real function rather than a copy of its jq, which is
the point: a mutation dropping sessionUrl from the write fails three of these.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are test-only and the added cases directly and safely cover the stated attribution-gating behaviors without modifying runtime code.

Pull request overview

Adds a dedicated Bats test suite to exercise the “attribution” prompt/gating logic inside configure_claude_settings (defined in ./setup) without sourcing the full installer script.

Changes:

  • Introduces test/setup-settings.bats with fixtures to source only the definition prefix of ./setup and invoke configure_claude_settings against an isolated $HOME.
  • Adds coverage for “offer vs. don’t offer” cases, pre-sessionUrl migration behavior, and “never overwrite user choice” scenarios.
  • Verifies the resulting settings file remains valid JSON and preserves unrelated keys.
File summaries
File Description
test/setup-settings.bats Adds 8 Bats tests validating the attribution gate/migration behavior in configure_claude_settings.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@rlorenzo
rlorenzo merged commit 12b8840 into main Aug 30, 2026
6 checks passed
@rlorenzo
rlorenzo deleted the test/setup-attribution-settings branch August 30, 2026 23:27
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.

2 participants