Skip to content

Commit

Permalink
Handle Numbers in Environment Variables (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraftp authored Nov 19, 2024
1 parent eaa9107 commit 5de7ca7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dbos/_dbos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@ def _app_name_to_db_name(app_name: str) -> str:
def _set_env_vars(config: ConfigFile) -> None:
for env, value in config.get("env", {}).items():
if value is not None:
os.environ[env] = value
os.environ[env] = str(value)
3 changes: 3 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_valid_config(mocker):
foo: ${BARBAR}
bazbaz: BAZBAZ
bob: ${BOBBOB}
test_number: 123
"""
os.environ["BARBAR"] = "FOOFOO"
mocker.patch(
Expand All @@ -61,10 +62,12 @@ def test_valid_config(mocker):
assert configFile["database"]["connectionTimeoutMillis"] == 3000
assert configFile["env"]["foo"] == "FOOFOO"
assert configFile["env"]["bob"] is None # Unset environment variable
assert configFile["env"]["test_number"] == 123

_set_env_vars(configFile)
assert os.environ["bazbaz"] == "BAZBAZ"
assert os.environ["foo"] == "FOOFOO"
assert os.environ["test_number"] == "123"
assert "bob" not in os.environ


Expand Down

0 comments on commit 5de7ca7

Please sign in to comment.