Skip to content

Commit 22e75e5

Browse files
committed
test(list-directory): add test for empty directory (#170)
Add test case for list-directory command when directory is empty, using mock to return empty file list.
1 parent 7c65a79 commit 22e75e5

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tests/test_cli_list_directory.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,13 @@ def test_recursive_list_directory_wrong():
6666
assert (
6767
"Directory /eos/opendata/recursiveFoobar does not exist." in test_result.output
6868
)
69+
70+
71+
@pytest.mark.local
72+
def test_list_directory_empty(mocker):
73+
"""Test `list_directory` command with empty directory."""
74+
mocker.patch("cernopendata_client.cli.get_list_directory", return_value=[])
75+
test_empty = CliRunner()
76+
test_result = test_empty.invoke(list_directory, ["/eos/opendata/test"])
77+
assert test_result.exit_code == 2
78+
assert "No files in the directory" in test_result.output

0 commit comments

Comments
 (0)