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
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# Model catalogues: fetched by each provider's kind, cached per server.
|
||||
. "$(dirname "$0")/../lib.sh"
|
||||
start_fake
|
||||
C="$CM_ROOT/models-cache.json"
|
||||
|
||||
ready_preset ollama "$OLLAMA_URL"
|
||||
run_cm models --preset ollama
|
||||
expect_out 'qwen3-coder:latest' 'ollama models are listed'
|
||||
run_cm models --preset ollama --refresh
|
||||
expect_out 'cached 2 ollama model(s)' 'and cached'
|
||||
expect_eq "$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["providers"]["ollama"]["baseUrl"])' "$C")" \
|
||||
"$OLLAMA_URL" 'against the server they came from'
|
||||
|
||||
ready_preset lmstudio "$LMSTUDIO_URL"
|
||||
run_cm models --preset lmstudio
|
||||
expect_out 'qwen3-coder-30b' 'lm studio models are listed'
|
||||
|
||||
python3 - "$P/custom.json" "$KEYED_URL" <<'PY'
|
||||
import json, sys
|
||||
p = json.load(open(sys.argv[1]))
|
||||
p.update(baseUrl=sys.argv[2], auth={"mode": "literal", "token": "sk-real"}, configured=True)
|
||||
json.dump(p, open(sys.argv[1], "w"), indent=2)
|
||||
PY
|
||||
run_cm models --preset custom
|
||||
expect_out 'gw/model-b' 'a keyed endpoint lists its models with the key'
|
||||
|
||||
cp "$P/custom.json" "$P/proxy.json"
|
||||
python3 "$J" set-url "$P/proxy.json" "$PROXY_URL" >/dev/null
|
||||
run_cm models --preset proxy --refresh
|
||||
expect_rc 1 'a proxy has no list to fetch'
|
||||
expect_out 'model ids can still be typed by hand' 'and that is explained'
|
||||
|
||||
run_cm models --preset zai
|
||||
expect_out 'glm-5.3' 'the static zai list'
|
||||
run_cm models --preset zai --json
|
||||
expect_out '"glm-4.7"' '--json prints the cached node'
|
||||
|
||||
run_cm models --preset nope --refresh
|
||||
expect_rc 1 'an unknown preset is refused'
|
||||
|
||||
for word in keyRef token auth; do
|
||||
case "$(cat "$C")" in *"\"$word\""*) fail "the cache holds a $word" ;; *) pass ;; esac
|
||||
done
|
||||
|
||||
finish
|
||||
Reference in New Issue
Block a user