Example #1
0
    def test_get_latest_commit_command_not_found(self, sh):
        sh.git.side_effect = CommandNotFound("git")
        expected_msg = "'git' command not found. You need to install git to use gitlint on a local repository. " + \
                       "See https://git-scm.com/book/en/v2/Getting-Started-Installing-Git on how to install git."
        with self.assertRaisesMessage(GitNotInstalledError, expected_msg):
            GitContext.from_local_repository("fåke/path")

        # assert that commit message was read using git command
        sh.git.assert_called_once_with("log", "-1", "--pretty=%H", **self.expected_sh_special_args)
Example #2
0
 def test_git_error(self, sh, _):
     """ Tests that the cli handles git errors properly """
     sh.git.side_effect = CommandNotFound("git")
     result = self.cli.invoke(cli.cli)
     self.assertEqual(result.exit_code, self.GIT_CONTEXT_ERROR_CODE)