Skip to content

test: add BATS test suite for setup.sh (39 tests) - #2

Merged
RiCSaucd merged 2 commits into
copilot/connect-to-claudecode-hermesfrom
copilot/analyze-test-coverage
Jul 5, 2026
Merged

test: add BATS test suite for setup.sh (39 tests)#2
RiCSaucd merged 2 commits into
copilot/connect-to-claudecode-hermesfrom
copilot/analyze-test-coverage

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

The repository had zero test coverage for setup.sh, leaving all configuration defaults, helper functions, external-command interactions, and the end-to-end setup flow completely untested.

What's added — tests/setup.bats

  • Default config & env overrides — asserts all three HERMES_* defaults and that each can be overridden via env vars
  • Helper functionsinfo() stdout format, warn() stderr format, error() stderr output + exit code
  • check_claude_installed — CLI found/missing, correct error message, version display
  • check_api_reachable — curl success/failure paths; failure is non-fatal and emits an Ollama hint
  • export_env_vars — maps HERMES_*ANTHROPIC_* correctly and logs both
  • write_env_file — creates .env.hermes with all three variables, valid shell syntax, overwrites existing file
  • pull_ollama_model — absent/present ollama, pull failure is non-fatal, uses the configured model name
  • main integration — full happy path, .env.hermes creation, hard-fail when claude is missing, custom env vars propagate to the output file, startup banner content

External commands (claude, curl, ollama) are stubbed as minimal shell scripts injected at the front of PATH per test, keeping tests hermetic.

Run with:

bats tests/setup.bats

Copilot AI and others added 2 commits May 20, 2026 12:38
@RiCSaucd
RiCSaucd marked this pull request as ready for review July 5, 2026 21:52
Copilot AI review requested due to automatic review settings July 5, 2026 21:52
@RiCSaucd
RiCSaucd merged commit f01addd into copilot/connect-to-claudecode-hermes Jul 5, 2026
1 check passed

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.

Pull request overview

Adds a BATS test suite to cover setup.sh’s defaults, helper functions, external-command checks, and end-to-end behavior by stubbing claude, curl, and ollama as needed.

Changes:

  • Introduces tests/setup.bats with coverage for config defaults/overrides, helper logging functions, and setup flow behaviors.
  • Adds hermetic command stubbing patterns for claude, curl, and ollama in tests (though a few tests still rely on host PATH state and need adjustment).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/setup.bats

setup() {
# Each test runs inside an isolated temp directory.
TEST_DIR="$(mktemp -d)"
Comment thread tests/setup.bats
Comment on lines +159 to +162
run bash -c '
source <(sed "s/^main \"\\\$@\"\$/: # disabled/" '"${BATS_TEST_DIRNAME}/../setup.sh"')
check_claude_installed 2>&1
'
Comment thread tests/setup.bats
Comment on lines +169 to +172
run bash -c '
source <(sed "s/^main \"\\\$@\"\$/: # disabled/" '"${BATS_TEST_DIRNAME}/../setup.sh"')
check_claude_installed 2>&1
'
Comment thread tests/setup.bats
Comment on lines +387 to +390
run bash -c '
source <(sed "s/^main \"\\\$@\"\$/: # disabled/" '"${BATS_TEST_DIRNAME}/../setup.sh"')
pull_ollama_model
'
Comment thread tests/setup.bats
Comment on lines +397 to +400
run bash -c '
source <(sed "s/^main \"\\\$@\"\$/: # disabled/" '"${BATS_TEST_DIRNAME}/../setup.sh"')
pull_ollama_model
'
Comment thread tests/setup.bats
Comment on lines +486 to +487
printf '#!/bin/sh\nexit 0\n' > "$bin_dir/curl"
chmod +x "$bin_dir/curl"
Comment thread tests/setup.bats
Comment on lines +513 to +514
printf '#!/bin/sh\nexit 0\n' > "$bin_dir/curl"
chmod +x "$bin_dir/curl"
Comment thread tests/setup.bats
Comment on lines +532 to +533
printf '#!/bin/sh\nexit 0\n' > "$bin_dir/curl"
chmod +x "$bin_dir/curl"
Comment thread tests/setup.bats
Comment on lines +551 to +552
printf '#!/bin/sh\nexit 0\n' > "$bin_dir/curl"
chmod +x "$bin_dir/curl"
Comment thread tests/setup.bats
Comment on lines +501 to +503
run bash -c '
bash '"${BATS_TEST_DIRNAME}/../setup.sh"' 2>&1
'
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.

3 participants