Tests, licence, and the tooling to keep the repo consistent
A test suite with no dependencies beyond bash and the Python standard library, run by one command: scripts/test.sh (or: make test) scripts/test.sh --windows [host] adds the PowerShell suite over SSH - tests/static.sh: script syntax, JSON validity, VERSION against the widget manifest and CHANGELOG, providers.json against the kinds, probes and checks the code implements (and ids that would shadow a command), qmllint and shellcheck when installed. - tests/python: unit tests for cm-json.py - providers and the column contract bash depends on, the original three scaffolds byte for byte, every catalogue parser and the cache, session scan/dismiss/repair, rename, defaults, health, the cost guard. - tests/cli: the CLI in a sandbox with its own HOME, CM_ROOT, CLAUDE_CONFIG_DIR and a file-only vault, against fake Ollama, LM Studio, keyed-gateway and proxy servers - preflight, presets, models, doctor, a real switch, sessions, and the key helper under a rename race. - tests/windows: the same idea on a Windows host, with USERPROFILE pointed at a temp folder so the real install is never touched. Also: MIT licence, CHANGELOG.md reconstructed from history, .editorconfig and .gitattributes pinning LF everywhere (what the tree already is), and scripts/bump-version.sh, since the version lives in two files and drifted once before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# A real switch - into the sandbox's own settings.json - and editing the preset
|
||||
# in use. --yes because the machine running the tests may well have Claude Code
|
||||
# sessions open; with --yes the CLI proceeds and leaves them alone.
|
||||
. "$(dirname "$0")/../lib.sh"
|
||||
start_fake
|
||||
S="$CLAUDE_CONFIG_DIR/settings.json"
|
||||
|
||||
ready_preset ollama "$OLLAMA_URL"
|
||||
run_cm ollama --yes
|
||||
expect_rc 0 'switch to ollama'
|
||||
expect_eq "$(jget "$S" env.ANTHROPIC_BASE_URL)" "$OLLAMA_URL" 'base url written'
|
||||
expect_eq "$(jget "$S" env.ANTHROPIC_AUTH_TOKEN)" ollama 'placeholder token written'
|
||||
expect_eq "$(jget "$S" env.ANTHROPIC_DEFAULT_OPUS_MODEL)" qwen3-coder 'tier mapped'
|
||||
expect_eq "$(jget "$S" env.CLAUDE_CODE_MAX_CONTEXT_TOKENS)" 65536 'context declared'
|
||||
expect_eq "$(jget "$S" env.CLAUDE_CODE_ATTRIBUTION_HEADER)" 0 'extra env written'
|
||||
expect_eq "$(jget "$CM_ROOT/state.json" mode)" ollama 'state records the mode'
|
||||
expect_eq "$(jget "$CM_ROOT/health.json" preset)" ollama 'health.json follows'
|
||||
|
||||
run_cm anthropic --yes
|
||||
expect_rc 0 'switch back to anthropic'
|
||||
expect_eq "$(jget "$S" env.ANTHROPIC_BASE_URL)" '' 'gateway env removed'
|
||||
expect_eq "$(jget "$S" env.CLAUDE_CODE_ATTRIBUTION_HEADER)" '' 'including the extra env'
|
||||
|
||||
# The preset in use: a tier edit re-applies without asking about sessions.
|
||||
set_state openrouter default
|
||||
run_cm preset set default sonnet test/model-c --force
|
||||
expect_rc 0 'a tier edit on the active preset re-applies'
|
||||
expect_no_out 'refusing to switch while sessions are running' 'without the sessions prompt'
|
||||
expect_eq "$(jget "$S" env.ANTHROPIC_DEFAULT_SONNET_MODEL)" test/model-c 'and reaches settings.json'
|
||||
|
||||
run_cm preset set default opus anthropic/claude-opus-5 --force
|
||||
expect_rc 1 'the cost guard still refuses an Anthropic model'
|
||||
expect_out 'saved, but re-applying the active preset failed' 'and says the edit was saved'
|
||||
|
||||
finish
|
||||
Reference in New Issue
Block a user