@@ -27,6 +27,21 @@ def test_collect_go_setup_info_skip_confirm_uses_defaults(tmp_path: Path, monkey
2727 assert setup_info .disable_telemetry is False
2828
2929
30+ def test_collect_go_setup_info_uses_default_telemetry_on_eof (tmp_path : Path , monkeypatch ) -> None :
31+ monkeypatch .chdir (tmp_path )
32+ (tmp_path / "go.mod" ).write_text ("module example.com/demo\n \n go 1.21\n " , encoding = "utf-8" )
33+
34+ get_git_remote = Mock (return_value = "origin" )
35+ monkeypatch .setattr ("codeflash.cli_cmds.init_go._get_git_remote_for_setup" , get_git_remote )
36+
37+ with patch ("rich.prompt.Confirm.ask" , side_effect = EOFError ):
38+ setup_info = collect_go_setup_info ()
39+
40+ get_git_remote .assert_called_once_with ()
41+ assert setup_info .git_remote == "origin"
42+ assert setup_info .disable_telemetry is False
43+
44+
3045def test_collect_java_setup_info_skip_confirm_uses_defaults (tmp_path : Path , monkeypatch ) -> None :
3146 monkeypatch .chdir (tmp_path )
3247 (tmp_path / "build.gradle" ).write_text ("plugins { id 'java' }\n " , encoding = "utf-8" )
@@ -52,6 +67,30 @@ def test_collect_java_setup_info_skip_confirm_uses_defaults(tmp_path: Path, monk
5267 assert setup_info .disable_telemetry is False
5368
5469
70+ def test_collect_java_setup_info_uses_defaults_on_eof (tmp_path : Path , monkeypatch ) -> None :
71+ monkeypatch .chdir (tmp_path )
72+ (tmp_path / "build.gradle" ).write_text ("plugins { id 'java' }\n " , encoding = "utf-8" )
73+ (tmp_path / "src" / "main" / "java" ).mkdir (parents = True )
74+ (tmp_path / "src" / "test" / "java" ).mkdir (parents = True )
75+
76+ get_git_remote = Mock (return_value = "origin" )
77+ monkeypatch .setattr ("codeflash.cli_cmds.init_java._get_git_remote_for_setup" , get_git_remote )
78+ monkeypatch .setattr ("codeflash.cli_cmds.init_config.ask_for_telemetry" , Mock (return_value = True ))
79+
80+ with patch ("codeflash.cli_cmds.init_java.inquirer" ) as mock_inquirer , patch (
81+ "rich.prompt.Confirm.ask" , side_effect = EOFError
82+ ):
83+ setup_info = collect_java_setup_info ()
84+
85+ mock_inquirer .prompt .assert_not_called ()
86+ get_git_remote .assert_called_once_with ()
87+ assert setup_info .module_root_override is None
88+ assert setup_info .test_root_override is None
89+ assert setup_info .formatter_override is None
90+ assert setup_info .git_remote == "origin"
91+ assert setup_info .disable_telemetry is False
92+
93+
5594def test_should_modify_java_config_skip_confirm_skips_reconfigure_prompt (tmp_path : Path , monkeypatch ) -> None :
5695 monkeypatch .chdir (tmp_path )
5796 (tmp_path / "build.gradle" ).write_text ("plugins { id 'java' }\n " , encoding = "utf-8" )
@@ -62,3 +101,15 @@ def test_should_modify_java_config_skip_confirm_skips_reconfigure_prompt(tmp_pat
62101
63102 assert should_modify is False
64103 assert config is None
104+
105+
106+ def test_should_modify_java_config_uses_default_on_eof (tmp_path : Path , monkeypatch ) -> None :
107+ monkeypatch .chdir (tmp_path )
108+ (tmp_path / "build.gradle" ).write_text ("plugins { id 'java' }\n " , encoding = "utf-8" )
109+ (tmp_path / "gradle.properties" ).write_text ("codeflash.moduleRoot=src/main/java\n " , encoding = "utf-8" )
110+
111+ with patch ("rich.prompt.Confirm.ask" , side_effect = EOFError ):
112+ should_modify , config = should_modify_java_config ()
113+
114+ assert should_modify is False
115+ assert config is None
0 commit comments