Skip to content

Commit

Permalink
Fixed error when returning empty bucket, closes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Aug 12, 2022
1 parent 5a9814d commit 30e07d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion s3_credentials/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ def stream_indented_json(iterator, indent=2):
def paginate(service, method, list_key, **kwargs):
paginator = service.get_paginator(method)
for response in paginator.paginate(**kwargs):
yield from response[list_key]
yield from response.get(list_key) or []


def fix_json(row):
Expand Down
9 changes: 9 additions & 0 deletions tests/test_s3_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,15 @@ def test_list_bucket(stub_s3, options, expected):
assert result.output == expected


def test_list_bucket_empty(stub_s3):
stub_s3.add_response("list_objects_v2", {})
runner = CliRunner()
with runner.isolated_filesystem():
result = runner.invoke(cli, ["list-bucket", "test-bucket"])
assert result.exit_code == 0
assert result.output == "[]\n"


@pytest.fixture
def stub_iam_for_list_roles(stub_iam):
stub_iam.add_response(
Expand Down

0 comments on commit 30e07d3

Please sign in to comment.