Scrub real machine hostname from README and test fixtures

This commit is contained in:
neil 2026-11-05 01:29:45 -08:00
parent c8f04f49b7
commit d07a92e5b5
2 changed files with 34 additions and 34 deletions

View file

@ -47,21 +47,21 @@ check("limits come from the loaded model",
check("reasoning flag from the loaded model", mods["default"].get("reasoning") is True, mods["default"])
print("\n2. local + remote side by side")
rp, rb = remote("popos.local")
rp, rb = remote("mybox.local")
reset({"provider": {rp: rb}, "model": f"{rp}/qwen3.8-27b"})
st, path, prov, authcl = opencode.configure(CFG)
d = load()
check("remote id is llmhost-popos", rp == "llmhost-popos", rp)
check('remote name is "LLMHost (popos.local)"', rb["name"] == "LLMHost (popos.local)", rb["name"])
check("remote id is llmhost-mybox", rp == "llmhost-mybox", rp)
check('remote name is "LLMHost (mybox.local)"', rb["name"] == "LLMHost (mybox.local)", rb["name"])
check("remote has one entry too", list(rb["models"]) == ["default"], list(rb["models"]))
check("remote label names no model (it would go stale)",
rb["models"]["default"]["name"] == "Default model (popos.local)", rb["models"]["default"]["name"])
check("local added alongside", sorted(d["provider"]) == ["llmhost", "llmhost-popos"], sorted(d["provider"]))
rb["models"]["default"]["name"] == "Default model (mybox.local)", rb["models"]["default"]["name"])
check("local added alongside", sorted(d["provider"]) == ["llmhost", "llmhost-mybox"], sorted(d["provider"]))
check("remote untouched", d["provider"][rp] == rb)
check("existing model kept", d["model"] == f"{rp}/qwen3.8-27b", d["model"])
print("\n3. a REMOTE block squatting on the `llmhost` id (gap 1)")
_, rb2 = remote("popos.local", prov="llmhost")
_, rb2 = remote("mybox.local", prov="llmhost")
reset({"provider": {"llmhost": rb2}})
st, path, prov, authcl = opencode.configure(CFG)
d = load()
@ -83,7 +83,7 @@ check("a stale default makes it an update", st == "updated", st)
check("and it is migrated", load()["model"] == "mymac/default", load().get("model"))
print("\n5. uninstall: remove local, keep remote, repoint model")
rp, rb = remote("popos.local")
rp, rb = remote("mybox.local")
reset({"provider": {"llmhost": opencode.local_block(CFG), rp: rb}, "model": "llmhost/default"})
st, path, removed, new_model = opencode.remove(local=True)
d = load()
@ -108,13 +108,13 @@ check("remote still there", list(load()["provider"]) == [rp])
print("\n7. retiring a remote server (gap 3)")
reset({"provider": {"llmhost": opencode.local_block(CFG), rp: rb}, "model": f"{rp}/qwen3.8-27b"})
st, path, removed, new_model = opencode.remove(local=False, host="popos.local")
st, path, removed, new_model = opencode.remove(local=False, host="mybox.local")
d = load()
check("removed the remote", removed == [rp], removed)
check("local survives", list(d["provider"]) == ["llmhost"], list(d["provider"]))
check("model repointed to local", d["model"].startswith("llmhost/"), d.get("model"))
reset({"provider": {"llmhost": opencode.local_block(CFG), rp: rb}})
st, path, removed, _ = opencode.remove(local=False, host="popos")
st, path, removed, _ = opencode.remove(local=False, host="mybox")
check("short hostname also matches", removed == [rp], removed)
print("\n8. --all drops the model key when nothing is left")
@ -126,15 +126,15 @@ check("model key dropped", "model" not in d and new_model is None, d)
check("provider key dropped", "provider" not in d, d)
print("\n9. foreign providers are never touched")
foreign = {"npm": "@ai-sdk/openai-compatible", "name": "vLLM (popos)",
"options": {"baseURL": "http://popos.local:1134/v1", "apiKey": "{file:~/.config/opencode/popos-vllm.key}"},
foreign = {"npm": "@ai-sdk/openai-compatible", "name": "vLLM (mybox)",
"options": {"baseURL": "http://mybox.local:1134/v1", "apiKey": "{file:~/.config/opencode/mybox-vllm.key}"},
"models": {"x": {"name": "x"}}}
reset({"provider": {"popos-vllm": foreign, "llmhost": opencode.local_block(CFG)}, "model": "popos-vllm/x"})
reset({"provider": {"mybox-vllm": foreign, "llmhost": opencode.local_block(CFG)}, "model": "mybox-vllm/x"})
st, path, removed, new_model = opencode.remove(local=True)
d = load()
check("only ours removed", removed == ["llmhost"], removed)
check("foreign intact", d["provider"]["popos-vllm"] == foreign)
check("foreign model untouched", d["model"] == "popos-vllm/x", d.get("model"))
check("foreign intact", d["provider"]["mybox-vllm"] == foreign)
check("foreign model untouched", d["model"] == "mybox-vllm/x", d.get("model"))
st, path, removed, _ = opencode.remove(local=False, every=True)
check("--all skips foreign", removed == [], removed)
@ -165,15 +165,15 @@ st, path, prov, authcl = opencode.configure(CFG)
check("still installs", prov == "llmhost" and st == "added", (prov, st))
print("\n13. --host must not take a foreign provider on the same host (regression)")
rp, rb = remote("popos.local")
reset({"provider": {rp: rb, "popos-vllm": foreign, "llmhost": opencode.local_block(CFG)},
"model": "popos-vllm/x"})
st, path, removed, new_model = opencode.remove(local=False, host="popos.local")
rp, rb = remote("mybox.local")
reset({"provider": {rp: rb, "mybox-vllm": foreign, "llmhost": opencode.local_block(CFG)},
"model": "mybox-vllm/x"})
st, path, removed, new_model = opencode.remove(local=False, host="mybox.local")
d = load()
check("removed only ours", removed == [rp], removed)
check("foreign on same host survives", "popos-vllm" in d["provider"])
check("foreign on same host survives", "mybox-vllm" in d["provider"])
check("local survives", "llmhost" in d["provider"])
check("foreign model untouched", d["model"] == "popos-vllm/x", d.get("model"))
check("foreign model untouched", d["model"] == "mybox-vllm/x", d.get("model"))
print("\n14. a stale cached key is cleared on configure")
def put_auth(d, mode=0o600):
@ -212,12 +212,12 @@ check("left verbatim", f.read_text() == "{ not json")
check("reported nothing cleared", authcl is False, authcl)
print("\n17. remove() takes the cached key with the provider")
reset({"provider": {"llmhost": opencode.local_block(CFG), "llmhost-popos": remote("popos.local")[1]}})
put_auth({"llmhost": {"type": "api", "key": "sk-A"}, "llmhost-popos": {"type": "api", "key": "sk-B"}})
reset({"provider": {"llmhost": opencode.local_block(CFG), "llmhost-mybox": remote("mybox.local")[1]}})
put_auth({"llmhost": {"type": "api", "key": "sk-A"}, "llmhost-mybox": {"type": "api", "key": "sk-B"}})
st, path, removed, _ = opencode.remove(local=True)
a = get_auth()
check("local cred cleared", "llmhost" not in a, a)
check("remote cred kept", a.get("llmhost-popos") == {"type": "api", "key": "sk-B"}, a)
check("remote cred kept", a.get("llmhost-mybox") == {"type": "api", "key": "sk-B"}, a)
print("\n18. purge --keep-key keeps the API key through a purge")
from llmhost import cli
@ -276,9 +276,9 @@ print("\n21. sync() never wires opencode up on its own")
reset()
check("no config file -> no-op", opencode.sync(CFG) is None)
check("still no config file", not opencode.config_file().exists())
reset({"provider": {"popos-vllm": foreign}, "model": "popos-vllm/x"})
reset({"provider": {"mybox-vllm": foreign}, "model": "mybox-vllm/x"})
check("no local block -> no-op", opencode.sync(CFG) is None)
check("foreign provider untouched", load()["provider"] == {"popos-vllm": foreign})
check("foreign provider untouched", load()["provider"] == {"mybox-vllm": foreign})
reset({"provider": {"mymac": opencode.local_block(CFG)}})
check("finds a renamed local block", opencode.sync(dict(CFG, active="qwen3-coder")) == "mymac")
@ -286,8 +286,8 @@ check.section("22. a default naming a specific model is migrated to the alias")
for old_model, expect in (("llmhost/qwen3.8-27b", "llmhost/default"),
("llmhost/ornith-1.5-9b", "llmhost/default"),
("llmhost/default", "llmhost/default"),
("popos-vllm/qwen3.8-27b", "popos-vllm/qwen3.8-27b"),
("llmhost-popos/qwen3.8-27b", "llmhost-popos/qwen3.8-27b")):
("mybox-vllm/qwen3.8-27b", "mybox-vllm/qwen3.8-27b"),
("llmhost-mybox/qwen3.8-27b", "llmhost-mybox/qwen3.8-27b")):
reset({"provider": {"llmhost": opencode.local_block(CFG)}, "model": old_model})
opencode.configure(CFG)
got = load().get("model")
@ -301,10 +301,10 @@ import argparse, io, contextlib
cli._service_check = lambda: CFG
buf = io.StringIO()
with contextlib.redirect_stdout(buf):
cli.cmd_opencode(argparse.Namespace(host="popos.local", provider=None, json=True))
cli.cmd_opencode(argparse.Namespace(host="mybox.local", provider=None, json=True))
snip = json.loads(buf.getvalue())
prov_id, block = next(iter(snip["provider"].items()))
check("provider named after the host", prov_id == "llmhost-popos", prov_id)
check("provider named after the host", prov_id == "llmhost-mybox", prov_id)
check("model is <provider>/<an entry in the block>",
snip["model"].partition("/")[0] == prov_id and snip["model"].partition("/")[2] in block["models"],
(snip["model"], list(block["models"])))
@ -313,7 +313,7 @@ check.section("24. the block never offers a reasoning chooser of its own")
check("opencode's whole menu is switched off",
opencode.effort_variants() == {l: {"disabled": True} for l in ("low", "medium", "high")},
opencode.effort_variants())
q = opencode.provider_block(dict(CFG, active="qwen3.8-27b"), "popos.local", "k", "popos.local")
q = opencode.provider_block(dict(CFG, active="qwen3.8-27b"), "mybox.local", "k", "mybox.local")
ent = q["models"]["default"]
check("a reasoning model is marked as one (so thinking blocks render)", ent.get("reasoning") is True, ent)
check("but every effort level is disabled",
@ -322,7 +322,7 @@ check("no variant carries a reasoningEffort to send",
not any("reasoningEffort" in v for v in ent["variants"].values()), ent["variants"])
check("the model levels from the catalog are not offered either",
not ({"xhigh"} & set(ent["variants"])), ent["variants"])
nr = opencode.provider_block(dict(CFG, active="qwen3-coder"), "popos.local", "k", "popos.local")
nr = opencode.provider_block(dict(CFG, active="qwen3-coder"), "mybox.local", "k", "mybox.local")
check("a non-reasoning model gets no variants", "variants" not in nr["models"]["default"], nr["models"]["default"])
check("one entry only, named for the alias, so the client can't pick a model either",
list(q["models"]) == [plan.SERVED_ALIAS], list(q["models"]))