def test_run(self, mock_repo_clone, mock_mkdtemp): mock_mkdtemp.return_value = self.temp_url action = vcs.GitCloneAction(self.container, self.git_url) action.run() mock_mkdtemp.assert_called() mock_repo_clone.assert_called_with(self.git_url, self.temp_url)
def test_run_repo_failure(self, mock_repo_clone, mock_mkdtemp): mock_mkdtemp.return_value = self.temp_url mock_repo_clone.side_effect = git.exc.GitCommandError action = vcs.GitCloneAction(self.container, self.git_url) result = action.run() expected = mistral_workflow_utils.Result( error="Error cloning remote repository: %s " % self.git_url) mock_mkdtemp.assert_called() mock_repo_clone.assert_called_with(self.git_url, self.temp_url) self.assertEqual(result, expected)
def test_run_ref_checkout_error(self, mock_checkout, mock_repo_clone, mock_mkdtemp): mock_mkdtemp.return_value = self.temp_url mock_checkout.side_effect = git.cmd.GitCommandError action = vcs.GitCloneAction( self.container, "{url}@{tag}".format(url=self.git_url, tag=self.tag_ref)) result = action.run() err_msg = ("Error checking out %s reference from remote " "repository %s" % (self.tag_ref, self.git_url)) expected = mistral_workflow_utils.Result(error=err_msg) self.assertEqual(result, expected, "Error messages don't match.") mock_mkdtemp.assert_called() mock_repo_clone.assert_called_with(self.git_url, self.temp_url)
def test_run_ref_not_found(self, mock_checkout, mock_repo_clone, mock_mkdtemp): mock_mkdtemp.return_value = self.temp_url mock_checkout.side_effect = IndexError action = vcs.GitCloneAction( self.container, "{url}@{tag}".format(url=self.git_url, tag=self.tag_ref)) result = action.run(self.ctx) err_msg = ("Error finding %s reference from remote repository" % self.tag_ref) expected = actions.Result(error=err_msg) self.assertEqual(result, expected, "Error messages don't match.") mock_mkdtemp.assert_called() mock_repo_clone.assert_called_with(self.git_url, self.temp_url)