-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement fetching dependencies for yarn regular workflow
* with new custom YarnCommandError * covered with unit tests JIRA: STONEBLD-1788 Signed-off-by: Michal Šoltis <[email protected]>
- Loading branch information
1 parent
80aecd8
commit a9e41e2
Showing
7 changed files
with
72 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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
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
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,26 @@ | ||
from unittest import mock | ||
|
||
import pytest | ||
|
||
from cachi2.core.errors import YarnCommandError | ||
from cachi2.core.package_managers.yarn.main import _fetch_dependencies | ||
from cachi2.core.rooted_path import RootedPath | ||
|
||
|
||
@mock.patch("cachi2.core.package_managers.yarn.main.run_yarn_cmd") | ||
def test_fetch_dependencies(mock_yarn_cmd: mock.Mock, rooted_tmp_path: RootedPath) -> None: | ||
source_dir = rooted_tmp_path | ||
output_dir = rooted_tmp_path.join_within_root("cachi2-output") | ||
|
||
mock_yarn_cmd.side_effect = YarnCommandError("berryscary") | ||
|
||
with pytest.raises(YarnCommandError) as exc_info: | ||
_fetch_dependencies(source_dir, output_dir) | ||
|
||
mock_yarn_cmd.assert_called_once_with( | ||
["install", "--mode", "skip-build"], | ||
source_dir, | ||
{"YARN_GLOBAL_FOLDER": str(output_dir.join_within_root("deps", "yarn"))}, | ||
) | ||
|
||
assert str(exc_info.value) == "berryscary" |
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