def test_scan_fails_on_scan_exception(self, mock_scanner: mock.MagicMock): mock_scanner.return_value.scan.side_effect = types.ScanException( "Scan failed!") runner = CliRunner() with runner.isolated_filesystem(): result = runner.invoke(cli.main, ["pre-commit"]) self.assertEqual(result.output, "Scan failed!\n")
def test_scan_exits_gracefully_on_scan_exception( self, mock_scanner: mock.MagicMock): mock_scanner.return_value.scan.side_effect = types.ScanException( "Scan failed!") runner = CliRunner() with runner.isolated_filesystem(): result = runner.invoke(cli.main, ["scan-local-repo", "."]) self.assertGreater(result.exit_code, 0) self.assertEqual(result.output, "Scan failed!\n")
def test_command_fails_on_scan_exception( self, mock_scanner: mock.MagicMock, mock_clone: mock.MagicMock ): mock_clone.return_value = "/foo" mock_scanner.return_value.scan.side_effect = types.ScanException("Scan failed!") runner = CliRunner() with runner.isolated_filesystem(): result = runner.invoke( cli.main, ["scan-remote-repo", "[email protected]:godaddy/tartufo.git"] ) self.assertEqual(result.output, "Scan failed!\n")