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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user