Skip to content

Commit

Permalink
Test proving $env works for datasette.yml, closes #2255
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Feb 7, 2024
1 parent f049103 commit 52a1dac
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,18 @@ async def test_plugin_config(ds_client):


@pytest.mark.asyncio
async def test_plugin_config_env(ds_client):
os.environ["FOO_ENV"] = "FROM_ENVIRONMENT"
assert {"foo": "FROM_ENVIRONMENT"} == ds_client.ds.plugin_config("env-plugin")
del os.environ["FOO_ENV"]
async def test_plugin_config_env(ds_client, monkeypatch):
monkeypatch.setenv("FOO_ENV", "FROM_ENVIRONMENT")
assert ds_client.ds.plugin_config("env-plugin") == {"foo": "FROM_ENVIRONMENT"}


@pytest.mark.asyncio
async def test_plugin_config_env_from_config(monkeypatch):
monkeypatch.setenv("FOO_ENV", "FROM_ENVIRONMENT_2")
datasette = Datasette(
config={"plugins": {"env-plugin": {"setting": {"$env": "FOO_ENV"}}}}
)
assert datasette.plugin_config("env-plugin") == {"setting": "FROM_ENVIRONMENT_2"}


@pytest.mark.asyncio
Expand Down

0 comments on commit 52a1dac

Please sign in to comment.