Skip to content

Commit 51fc54d

Browse files
committed
test: Cover the case of a bad data file for profiles_create
#13 Branch: Profiles-13 Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
1 parent 9d8ead4 commit 51fc54d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/commands/settings/test_profiles.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,3 +688,11 @@ def test_profiles_create_data_file(self, mock_console, mock_settings) -> None:
688688
assert profile.email == data_file_content["email"]
689689
assert profile.api_url == data_file_content["api_url"]
690690
assert profile.is_active == data_file_content["is_active"]
691+
692+
def test_profiles_create_bad_data_file(self, mock_console, mock_settings) -> None:
693+
"""Test error handling when data file is not found"""
694+
with patch("cforge.commands.settings.profiles.get_console", return_value=mock_console):
695+
with patch("cforge.commands.settings.profiles.typer.confirm", return_value=False):
696+
with pytest.raises(typer.Exit) as exc_info:
697+
profiles_create(mock_settings.contextforge_home / "does" / "not" / "exist")
698+
assert exc_info.value.exit_code == 1

0 commit comments

Comments
 (0)