test(docker): read persisted configuration as UTF-8 on Windows

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-19 13:02:26 +08:00
1 parent de8fbc3ad2
commit 3ab8082118
2 files changed
+5 -5

No files matched your search

+3 -3
View File
@@ -75,7 +75,7 @@ def main() -> None:
service["environment"].update(
NANOBOT_WEB_TOKEN=secret, NANOBOT_API_KEY=secret,
)
compose_path.write_text(json.dumps(config))
compose_path.write_text(json.dumps(config), encoding="utf-8")
try:
onboard = run("run", "--rm", "--no-deps", "-T", "nanobot-cli", "onboard")
assert "Overwrite?" not in onboard
@@ -92,7 +92,7 @@ def main() -> None:
wait_for(webui + "/")
assert set(run("ps", "--services").split()) == {"nanobot-gateway", "nanobot-api"}
path = data / "config.json"
saved = json.loads(path.read_text())
saved = json.loads(path.read_text(encoding="utf-8"))
password = saved["channels"]["websocket"]["tokenIssueSecret"]
api_key = saved["api"]["apiKey"]
logs = run("logs", "--no-color")
@@ -132,7 +132,7 @@ def main() -> None:
service["environment"].update(
NANOBOT_WEB_TOKEN="changed-env", NANOBOT_API_KEY="changed-env",
)
compose_path.write_text(json.dumps(config))
compose_path.write_text(json.dumps(config), encoding="utf-8")
run("up", "-d", "--force-recreate", "nanobot-gateway")
webui = endpoint("nanobot-gateway", 8765)
wait_for(webui + "/")
+2 -2
View File
@@ -47,9 +47,9 @@ def test_custom_secrets_survive_json_serialization(tmp_path, secret):
def test_restart_preserves_user_settings_and_credentials(tmp_path):
path = tmp_path / "config.json"
assert _initialize(path, "original-web", "original-api").returncode == 0
data = json.loads(path.read_text())
data = json.loads(path.read_text(encoding="utf-8"))
data["providers"]["custom"] = {"apiKey": "provider-key", "apiBase": "http://model:8000/v1"}
path.write_text(json.dumps(data))
path.write_text(json.dumps(data), encoding="utf-8")
previous = path.read_bytes()
result = _initialize(path, "replacement-web", "replacement-api")
assert result.returncode == 0, result.stderr