test: add BATS test suite for setup.sh (39 tests) - #2
Merged
RiCSaucd merged 2 commits intoJul 5, 2026
Merged
Conversation
…assing) Agent-Logs-Url: https://github.com/RiCSaucd/Claude-code-/sessions/95060e87-ccaa-48cf-927e-4b8349041510 Co-authored-by: RiCSaucd <178687549+RiCSaucd@users.noreply.github.com>
Agent-Logs-Url: https://github.com/RiCSaucd/Claude-code-/sessions/95060e87-ccaa-48cf-927e-4b8349041510 Co-authored-by: RiCSaucd <178687549+RiCSaucd@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
RiCSaucd
June 26, 2026 01:05
View session
RiCSaucd
marked this pull request as ready for review
July 5, 2026 21:52
There was a problem hiding this comment.
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.batswith coverage for config defaults/overrides, helper logging functions, and setup flow behaviors. - Adds hermetic command stubbing patterns for
claude,curl, andollamain 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.
|
|
||
| setup() { | ||
| # Each test runs inside an isolated temp directory. | ||
| TEST_DIR="$(mktemp -d)" |
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 on lines
+169
to
+172
| run bash -c ' | ||
| source <(sed "s/^main \"\\\$@\"\$/: # disabled/" '"${BATS_TEST_DIRNAME}/../setup.sh"') | ||
| check_claude_installed 2>&1 | ||
| ' |
Comment on lines
+387
to
+390
| run bash -c ' | ||
| source <(sed "s/^main \"\\\$@\"\$/: # disabled/" '"${BATS_TEST_DIRNAME}/../setup.sh"') | ||
| pull_ollama_model | ||
| ' |
Comment on lines
+397
to
+400
| run bash -c ' | ||
| source <(sed "s/^main \"\\\$@\"\$/: # disabled/" '"${BATS_TEST_DIRNAME}/../setup.sh"') | ||
| pull_ollama_model | ||
| ' |
Comment on lines
+486
to
+487
| printf '#!/bin/sh\nexit 0\n' > "$bin_dir/curl" | ||
| chmod +x "$bin_dir/curl" |
Comment on lines
+513
to
+514
| printf '#!/bin/sh\nexit 0\n' > "$bin_dir/curl" | ||
| chmod +x "$bin_dir/curl" |
Comment on lines
+532
to
+533
| printf '#!/bin/sh\nexit 0\n' > "$bin_dir/curl" | ||
| chmod +x "$bin_dir/curl" |
Comment on lines
+551
to
+552
| printf '#!/bin/sh\nexit 0\n' > "$bin_dir/curl" | ||
| chmod +x "$bin_dir/curl" |
Comment on lines
+501
to
+503
| run bash -c ' | ||
| bash '"${BATS_TEST_DIRNAME}/../setup.sh"' 2>&1 | ||
| ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.batsHERMES_*defaults and that each can be overridden via env varsinfo()stdout format,warn()stderr format,error()stderr output + exit codecheck_claude_installed— CLI found/missing, correct error message, version displaycheck_api_reachable— curl success/failure paths; failure is non-fatal and emits an Ollama hintexport_env_vars— mapsHERMES_*→ANTHROPIC_*correctly and logs bothwrite_env_file— creates.env.hermeswith all three variables, valid shell syntax, overwrites existing filepull_ollama_model— absent/present ollama, pull failure is non-fatal, uses the configured model namemainintegration — full happy path,.env.hermescreation, hard-fail whenclaudeis missing, custom env vars propagate to the output file, startup banner contentExternal commands (
claude,curl,ollama) are stubbed as minimal shell scripts injected at the front ofPATHper test, keeping tests hermetic.Run with: