-
-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Zip source directory should read from sh_work_dir (#560)
* fix: :zip:embedded source directory should read from sh_work_dir Signed-off-by: ANGkeith <[email protected]> * refactor: write to a tempfile instead of using fd * refactor: move tests out to own file * docs: add comments to explain code --------- Signed-off-by: ANGkeith <[email protected]>
- Loading branch information
Showing
2 changed files
with
75 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
from unittest.mock import MagicMock, Mock | ||
|
||
from package import BuildPlanManager | ||
|
||
|
||
def test_zip_source_path_sh_work_dir(): | ||
zs = Mock() | ||
zs.write_dirs = MagicMock() | ||
|
||
bpm = BuildPlanManager(args=Mock()) | ||
|
||
bpm.execute( | ||
build_plan=[ | ||
["sh", ".", "cd $(mktemp -d)\n echo pip install"], | ||
["zip:embedded", ".", "./python"], | ||
], | ||
zip_stream=zs, | ||
query=None, | ||
) | ||
|
||
zs.write_dirs.assert_called_once() | ||
|
||
zip_source_path = zs.write_dirs.call_args_list[0][0][0] | ||
assert zip_source_path != f"{os.getcwd()}" | ||
|
||
|
||
def test_zip_source_path(): | ||
zs = Mock() | ||
zs.write_dirs = MagicMock() | ||
|
||
bpm = BuildPlanManager(args=Mock()) | ||
|
||
bpm.execute( | ||
build_plan=[ | ||
["sh", ".", "echo pip install"], | ||
["zip:embedded", ".", "./python"], | ||
], | ||
zip_stream=zs, | ||
query=None, | ||
) | ||
|
||
zs.write_dirs.assert_called_once() | ||
|
||
zip_source_path = zs.write_dirs.call_args_list[0][0][0] | ||
assert zip_source_path == f"{os.getcwd()}" |