Skip to content

Commit

Permalink
test get for multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
duarte-pompeu committed Dec 8, 2023
1 parent febc153 commit c52dd9e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,32 @@ def test_list_no_file(cli):
assert (result.exit_code, result.output) == (1, "")


def test_get_existing_value(cli, dotenv_path):
def test_get_existing_value_single_file(cli, dotenv_path):
dotenv_path.write_text("a=b")

result = cli.invoke(dotenv_cli, ['--file', dotenv_path, 'get', 'a'])

assert (result.exit_code, result.output) == (0, "b\n")


@pytest.mark.parametrize(
"contents,expected_values",
(
(["a=1", "b=2"], {"a": "1", "b": "2"}),
(["b=2", "a=1"], {"a": "1", "b": "2"}),
(["a=1", "a=2"], {"a": "2"}),
)
)
def test_get_existing_value_multi_file(cli, contents, expected_values, dotenv_path, extra_dotenv_path):
dotenv_path.write_text(contents[0])
extra_dotenv_path.write_text(contents[1])

for key, value in expected_values.items():
result = cli.invoke(dotenv_cli, ['--file', dotenv_path, '--file', extra_dotenv_path, 'get', key])

assert (result.exit_code, result.output) == (0, f"{value}\n")


def test_get_non_existent_value(cli, dotenv_path):
result = cli.invoke(dotenv_cli, ['--file', dotenv_path, 'get', 'a'])
assert (result.exit_code, result.output) == (1, "")
Expand Down

0 comments on commit c52dd9e

Please sign in to comment.