44import threading
55from click .testing import CliRunner
66
7- from tgit .cli import app , set_terminal_title , version_callback
7+ from tgit .cli import app , set_process_title , set_terminal_title , version_callback
88
99
1010class TestCLI :
@@ -53,15 +53,17 @@ def test_version_callback_false(self, mock_print, mock_version):
5353 mock_ctx .exit .assert_not_called ()
5454
5555 @patch ("tgit.cli.threading.Thread" )
56+ @patch ("tgit.cli.set_process_title" )
5657 @patch ("tgit.cli.set_terminal_title" )
57- def test_app_starts_openai_import_thread (self , mock_set_terminal_title , mock_thread ):
58+ def test_app_starts_openai_import_thread (self , mock_set_terminal_title , mock_set_process_title , mock_thread ):
5859 """Test that app starts a thread for OpenAI import"""
5960 mock_thread_instance = MagicMock ()
6061 mock_thread .return_value = mock_thread_instance
6162
6263 # Directly call the app function to test the callback
6364 app .callback ()
6465
66+ mock_set_process_title .assert_called_once_with ("tgit" )
6567 mock_set_terminal_title .assert_called_once_with ("tgit" )
6668 # The app should run the callback and start the thread
6769 mock_thread .assert_called_once ()
@@ -88,6 +90,20 @@ def test_app_callback_registration(self):
8890 assert isinstance (app , click .Group )
8991 # Verify the app exists and is configured correctly
9092
93+ @patch ("tgit.cli.setproctitle_module.setproctitle" )
94+ def test_set_process_title_updates_process_name (self , mock_setproctitle ):
95+ """Test process title is updated when support is available."""
96+ set_process_title ("tgit" )
97+
98+ mock_setproctitle .assert_called_once_with ("tgit" )
99+
100+ @patch ("tgit.cli.setproctitle_module.setproctitle" , side_effect = RuntimeError ("boom" ))
101+ def test_set_process_title_ignores_errors (self , mock_setproctitle ):
102+ """Test process title errors do not break CLI startup."""
103+ set_process_title ("tgit" )
104+
105+ mock_setproctitle .assert_called_once_with ("tgit" )
106+
91107 @patch ("tgit.cli.sys.stdout.flush" )
92108 @patch ("tgit.cli.sys.stdout.write" )
93109 @patch ("tgit.cli.sys.stdout.isatty" , return_value = True )
0 commit comments