diff --git a/pyodide_lock/cli.py b/pyodide_lock/cli.py index af3c28e..dae782f 100644 --- a/pyodide_lock/cli.py +++ b/pyodide_lock/cli.py @@ -47,7 +47,7 @@ def add_wheels( """ sp = PyodideLockSpec.from_json(input) - add_wheels_to_spec( + sp = add_wheels_to_spec( sp, wheels, base_path=base_path, diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..41ec6d1 --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,26 @@ +from pathlib import Path +import gzip +import shutil + +from typer.testing import CliRunner +from pyodide_lock.cli import main + +DATA_DIR = Path(__file__).parent / "data" + + +runner = CliRunner() + +def test_cli_modify_file(test_wheel_list, tmp_path): + source_path = DATA_DIR / f"pyodide-lock-0.23.3.json.gz" + target_path = tmp_path / "pyodide-lock.json" + new_lock_path = tmp_path / "pyodide-lock.json" + + with gzip.open(source_path) as fh_in: + with target_path.open("wb") as fh_out: + shutil.copyfileobj(fh_in, fh_out) + + result = runner.invoke(main, ["--input="+str(target_path), "--output="+str(new_lock_path), str(test_wheel_list[0])]) + assert result.exit_code == 0 + assert target_path.read_text() != new_lock_path.read_text() + + \ No newline at end of file