diff --git a/src/pysonar_scanner/__main__.py b/src/pysonar_scanner/__main__.py index 786ae8f4..78beed36 100644 --- a/src/pysonar_scanner/__main__.py +++ b/src/pysonar_scanner/__main__.py @@ -50,6 +50,9 @@ def scan(): def do_scan(): app_logging.setup() + logging.info( + "Enhance your workflow: Pair pysonar with SonarQube Server per your license or SonarQube Cloud for deeper analysis, and try SonarQube-IDE in your favourite IDE." + ) logging.info("Starting Pysonar, the Sonar scanner CLI for Python") config = ConfigurationLoader.load() set_logging_options(config) diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index c2deff85..eaec6c7a 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -18,7 +18,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # import pathlib -from unittest.mock import patch, Mock +from unittest.mock import patch, Mock, call from pyfakefs import fake_filesystem_unittest as pyfakefs @@ -45,6 +45,7 @@ class TestMain(pyfakefs.TestCase): + @patch("pysonar_scanner.__main__.logging") @patch.object(pathlib.Path, "home", return_value=pathlib.Path("home/user")) @patch.object( ConfigurationLoader, @@ -61,7 +62,9 @@ class TestMain(pyfakefs.TestCase): ) @patch("pysonar_scanner.__main__.create_jre", return_value=JREResolvedPath(pathlib.Path("jre_path"))) @patch.object(ScannerEngine, "run", return_value=0) - def test_minimal_success_run(self, run_mock, create_jre_mock, provision_mock, load_mock, path_home_mock): + def test_minimal_success_run( + self, run_mock, create_jre_mock, provision_mock, load_mock, path_home_mock, mock_logging + ): exitcode = scan() self.assertEqual(exitcode, 0) @@ -84,6 +87,15 @@ def test_minimal_success_run(self, run_mock, create_jre_mock, provision_mock, lo self.assertEqual(expected_config, config) + info_logs = [ + call( + "Enhance your workflow: Pair pysonar with SonarQube Server per your license or SonarQube Cloud for deeper analysis, and try SonarQube-IDE in your favourite IDE." + ), + call("Starting Pysonar, the Sonar scanner CLI for Python"), + call("Starting the analysis..."), + ] + mock_logging.info.assert_has_calls(info_logs) + @patch.object(ConfigurationLoader, "load") def test_scan_with_exception(self, load_mock): load_mock.side_effect = Exception("Test exception")