Cover the ollama provider paths in the AI mock regression suite
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019hLK3wsDuKVAC37GgDqg6H
This commit is contained in:
@@ -38,6 +38,11 @@ for p in deepseek kimi zai minimax; do
|
||||
jq -e --arg p "$p" '.providers[$p].endpoints.anthropic // .providers[$p].endpoints.openai' \
|
||||
"$ROOT/cn/registry/ai-providers.json" > /dev/null || fail "provider $p has an endpoint"
|
||||
done
|
||||
jq -e '.providers.ollama | (.static_token == "ollama") and (.models_dynamic == true)
|
||||
and (.endpoints.anthropic == "http://localhost:11434")' \
|
||||
"$ROOT/cn/registry/ai-providers.json" > /dev/null || fail "ollama provider contract"
|
||||
jq -e '.combos["claude-code"].ollama.adapter' \
|
||||
"$ROOT/cn/registry/ai-compatibility.json" > /dev/null || fail "claude-code x ollama combo present"
|
||||
pass "AI registries parse with P0 providers"
|
||||
|
||||
# Secret file backend roundtrip with 0600
|
||||
@@ -59,8 +64,17 @@ fi
|
||||
if omarchy-cn-ai-profile-create bad codex deepseek "deepseek-v4-pro[1m]" > /dev/null 2>&1; then
|
||||
fail "codex rejects provider-namespace slug"
|
||||
fi
|
||||
omarchy-cn-ai-profile-create loc claude-code ollama qwen3-coder > /dev/null ||
|
||||
fail "dynamic-model provider accepts a runtime-listed model"
|
||||
pass "profile validation enforces combos, protocols, and allowlists"
|
||||
|
||||
# Static-token provider needs no stored secret; absent fields stay silent
|
||||
source "$ROOT/cn/lib/ai.sh"
|
||||
[[ $(cn_ai_resolve_key ollama) == "ollama" ]] || fail "ollama resolves its static token"
|
||||
static_out=$(cn_ai_static_token deepseek || true)
|
||||
[[ -z $static_out ]] || fail "absent static_token must print nothing" "$static_out"
|
||||
pass "static token resolution: fixed ollama key, silent absent field"
|
||||
|
||||
# claude-code env render for all three providers, exact endpoints
|
||||
source "$ROOT/cn/lib/ai.sh"
|
||||
declare -A bases=(
|
||||
@@ -77,6 +91,10 @@ for p in deepseek kimi zai minimax; do
|
||||
done
|
||||
out=$(cn_ai_render_env claude-code minimax "MiniMax-M3[1m]" sk-x)
|
||||
grep -qF "ANTHROPIC_DEFAULT_HAIKU_MODEL=MiniMax-M3" <<<"$out" || fail "minimax haiku slot falls back to default-coding"
|
||||
out=$(cn_ai_render_env claude-code ollama qwen3-coder "$(cn_ai_resolve_key ollama)")
|
||||
grep -qF "ANTHROPIC_BASE_URL=http://localhost:11434" <<<"$out" || fail "ollama base url" "$out"
|
||||
grep -q "ANTHROPIC_AUTH_TOKEN=ollama" <<<"$out" || fail "ollama static token rendered"
|
||||
grep -qF "ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen3-coder" <<<"$out" || fail "ollama haiku slot falls back to the chosen model"
|
||||
out=$(cn_ai_render_env opencode deepseek test-model sk-x)
|
||||
grep -q "DEEPSEEK_API_KEY=sk-x" <<<"$out" || fail "opencode deepseek env"
|
||||
if cn_ai_render_env opencode zai m k > /dev/null 2>&1; then
|
||||
@@ -107,7 +125,7 @@ class H(http.server.BaseHTTPRequestHandler):
|
||||
def do_POST(self):
|
||||
body = self.rfile.read(int(self.headers.get("Content-Length", 0)))
|
||||
key = self.headers.get("x-api-key") or (self.headers.get("Authorization") or "").replace("Bearer ", "")
|
||||
if key != "sk-secret-1":
|
||||
if key not in ("sk-secret-1", "ollama"):
|
||||
code = 401
|
||||
elif self.path == "/v1/messages" and b"messages" in body and self.headers.get("anthropic-version"):
|
||||
code = 200
|
||||
@@ -131,6 +149,7 @@ done
|
||||
|
||||
OMARCHYCN_AI_TEST_BASE_URL="http://127.0.0.1:$port" omarchy-cn-ai-test good | grep -q "PASS" || fail "anthropic mock 200"
|
||||
OMARCHYCN_AI_TEST_BASE_URL="http://127.0.0.1:$port" omarchy-cn-ai-test cdx | grep -q "PASS" || fail "codex responses mock 200"
|
||||
OMARCHYCN_AI_TEST_BASE_URL="http://127.0.0.1:$port" omarchy-cn-ai-test loc | grep -q "PASS" || fail "ollama static-token mock 200"
|
||||
echo "wrong-key" | omarchy-cn-ai-secret set deepseek > /dev/null
|
||||
if OMARCHYCN_AI_TEST_BASE_URL="http://127.0.0.1:$port" omarchy-cn-ai-test good > /dev/null 2>&1; then
|
||||
fail "anthropic mock 401 fails the test"
|
||||
@@ -165,3 +184,11 @@ PATH="$restricted" omarchy-cn-ai-default good > /dev/null
|
||||
[[ $(stat -c %a "$HOME/.claude/settings.json") == 600 ]] || fail "claude settings 0600"
|
||||
[[ -f $TEST_HOME/installer-ran ]] || fail "missing harness triggered installer"
|
||||
pass "ai-default maps the profile onto the upstream agent entry"
|
||||
|
||||
# ai-default with the static-token local provider writes the official contract
|
||||
PATH="$restricted" omarchy-cn-ai-default loc > /dev/null
|
||||
[[ $(jq -r '.env.ANTHROPIC_BASE_URL' "$HOME/.claude/settings.json") == "http://localhost:11434" ]] || fail "ollama ai-default base url"
|
||||
[[ $(jq -r '.env.ANTHROPIC_AUTH_TOKEN' "$HOME/.claude/settings.json") == "ollama" ]] || fail "ollama ai-default static token"
|
||||
[[ $(jq -r '.env.ANTHROPIC_DEFAULT_HAIKU_MODEL' "$HOME/.claude/settings.json") == "qwen3-coder" ]] || fail "ollama ai-default haiku fallback"
|
||||
[[ $(jq -r '.env.KEEP' "$HOME/.claude/settings.json") == 1 ]] || fail "ollama ai-default preserves user env"
|
||||
pass "ai-default renders the ollama static-token contract"
|
||||
|
||||
Reference in New Issue
Block a user