|
|
@@ -10,13 +10,15 @@ from pathlib import Path
|
|
|
import cipy
|
|
|
import cipy.script
|
|
|
|
|
|
+from matchers import HasAttributes
|
|
|
+
|
|
|
|
|
|
def mock_run(
|
|
|
args: typing.Sequence[str],
|
|
|
*,
|
|
|
stdout: int | None = None,
|
|
|
stderr: int | None = None,
|
|
|
- check: bool, # Force an error if any of our mocked runs doesnt specify check
|
|
|
+ check: bool, # Force an error if any of our mocked runs doesnt specify check
|
|
|
**kwargs: typing.Any,
|
|
|
):
|
|
|
return subprocess.CompletedProcess(
|
|
|
@@ -39,7 +41,7 @@ def test_node_run_runs_main() -> None:
|
|
|
action = cipy.script.NodeScript(name="example", main=Path("/dev/null"))
|
|
|
action.run(cipy.Context())
|
|
|
|
|
|
- assert subprocess.run.call_args_list[0][0] == (["node", "/dev/null"],)
|
|
|
+ assert subprocess.run.call_args_list[0].args == (["node", "/dev/null"],)
|
|
|
|
|
|
|
|
|
def test_node_cleanup_noop_without_post() -> None:
|
|
|
@@ -90,7 +92,7 @@ def test_script_performs_mustache_substitution() -> None:
|
|
|
action.run(cipy.Context(foo=1))
|
|
|
|
|
|
|
|
|
-def test_script_propogates_mustache_error() -> None:
|
|
|
+def test_script_propogates_mustache_error(ci_logger) -> None:
|
|
|
action = cipy.script.Script(script="""
|
|
|
echo {{ foo }}
|
|
|
""")
|
|
|
@@ -98,3 +100,7 @@ def test_script_propogates_mustache_error() -> None:
|
|
|
subprocess.run.side_effect = RuntimeError("Should not be reached")
|
|
|
|
|
|
assert action.run(cipy.Context()) is cipy.Status.FAILURE
|
|
|
+ record = ci_logger.format.call_args_list[0][0][0]
|
|
|
+ ci_logger.format.assert_called_with(
|
|
|
+ HasAttributes(name="Script", message="Could not find key 'foo'\n")
|
|
|
+ )
|