fix(clients): hermetic tests ignore .env.json.local unless MOLO_LIVE_NET is set

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 04:46:35 +02:00
co-authored by Claude Sonnet 5.5
parent 5a54982339
commit d92baa5de5
4 changed files with 10 additions and 2 deletions
+5
View File
@@ -43,6 +43,11 @@ std::string from_json_file(const char* path, const char* name) {
// secrets), then .env.json, both in the working directory.
std::string Credentials::env(const char* name) {
if (const char* v = std::getenv(name); v && *v) return v;
// Test runs set MOLO_ENV_FILES=off so a developer's .env.json.local never
// leaks into hermetic tests; opt-in live runs (MOLO_LIVE_NET) need it.
const char* files = std::getenv("MOLO_ENV_FILES");
if (files && std::string(files) == "off" && !std::getenv("MOLO_LIVE_NET"))
return "";
std::string local = from_json_file(".env.json.local", name);
if (!local.empty()) return local;
return from_json_file(".env.json", name);