-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from logchange/8-fix-fail-when-cmd-fails
Fail release process when one from commands return non-zero code.
- Loading branch information
Showing
4 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import unittest | ||
from unittest.mock import patch, Mock, call | ||
from valhalla.commit.before import execute # Adjust the import according to your module structure | ||
|
||
|
||
class TestExecuteFunction(unittest.TestCase): | ||
|
||
@patch('valhalla.commit.before.exit') | ||
@patch('valhalla.commit.before.resolve') | ||
@patch('valhalla.commit.before.info') | ||
@patch('valhalla.commit.before.error') | ||
def test_execute_success(self, mock_error: Mock, mock_info: Mock, mock_resolve: Mock, mock_exit: Mock): | ||
mock_resolve.side_effect = lambda x: x # Simply return the command itself | ||
|
||
execute(["echo 'Hello World'"]) | ||
|
||
mock_info.assert_has_calls([call("Output for command 'echo 'Hello World'':\nHello World\n"), | ||
call("Successfully executed command: 'echo 'Hello World''")]) | ||
mock_error.assert_not_called() | ||
mock_exit.assert_not_called() | ||
|
||
@patch('valhalla.commit.before.exit') | ||
@patch('valhalla.commit.before.resolve') | ||
@patch('valhalla.commit.before.info') | ||
@patch('valhalla.commit.before.error') | ||
def test_execute_error(self, mock_error: Mock, mock_info: Mock, mock_resolve: Mock, mock_exit: Mock): | ||
mock_resolve.side_effect = lambda x: x # Simply return the command itself | ||
|
||
execute(["mvn clean"]) | ||
|
||
mock_exit.assert_called_with(1) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters