Skip to content

Commit

Permalink
Don't crash on startup with no config, closes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Sep 1, 2024
1 parent 5dfbc9e commit 46b5381
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions datasette_acl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async def inner():
[{"name": n} for n in datasette.permissions.keys()],
)
# And any dynamic groups
config = datasette.plugin_config("datasette-acl")
config = datasette.plugin_config("datasette-acl") or {}
groups = config.get("dynamic-groups")
if groups:
await db.execute_write_many(
Expand Down Expand Up @@ -199,7 +199,7 @@ async def update_dynamic_groups(datasette, actor, skip_cache=False):
# Don't do this more than once a second per actor
return
one_second_cache.set(actor["id"], 1)
config = datasette.plugin_config("datasette-acl")
config = datasette.plugin_config("datasette-acl") or {}
groups = config.get("dynamic-groups")
if not groups:
return
Expand Down
9 changes: 9 additions & 0 deletions tests/test_startup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from datasette.app import Datasette
import pytest


@pytest.mark.asyncio
async def test_can_startup_with_no_configuration():
datasette = Datasette()
await datasette.invoke_startup()
assert (await datasette.client.get("/")).status_code == 200

0 comments on commit 46b5381

Please sign in to comment.