Ejemplo n.º 1
0
def test_generate_node_command(
    command: str, mocker: MockerFixture, opts: List[str], tmp_path: Path
) -> None:
    """Test generate_node_command."""
    mock_which = mocker.patch(f"{MODULE}.which", return_value=False)
    assert generate_node_command(command, opts, tmp_path) == [
        str(tmp_path / "node_modules" / ".bin" / command),
        *opts,
    ]
    mock_which.assert_called_once_with(NPX_BIN)
Ejemplo n.º 2
0
def test_generate_node_command_npx(
    command: str,
    expected: List[str],
    mocker: MockerFixture,
    opts: List[str],
    tmp_path: Path,
) -> None:
    """Test generate_node_command."""
    mock_which = mocker.patch(f"{MODULE}.which", return_value=True)
    assert generate_node_command(command, opts, tmp_path) == expected
    mock_which.assert_called_once_with(NPX_BIN)
Ejemplo n.º 3
0
def test_generate_node_command_npx_package(
    mocker: MockerFixture, tmp_path: Path
) -> None:
    """Test generate_node_command."""
    mock_which = mocker.patch(f"{MODULE}.which", return_value=True)
    assert (
        generate_node_command(
            command="cdk",
            command_opts=["--context", "key=val"],
            package="aws-cdk",
            path=tmp_path,
        )
        == [NPX_BIN, "--package", "aws-cdk", "cdk", "--context", "key=val"]
    )
    mock_which.assert_called_once_with(NPX_BIN)