Skip to content

Commit

Permalink
fix: Reintroduce the uninstall command
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <[email protected]>
  • Loading branch information
jjerphan committed Dec 3, 2024
1 parent c9eddf3 commit 81ea936
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions micromamba/src/umamba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ set_umamba_command(CLI::App* com, mamba::Configuration& config)
CLI::App* remove_subcom = com->add_subcommand("remove", "Remove packages from active environment");
set_remove_command(remove_subcom, config);

// `uninstall` is an alias for `remove`
CLI::App* uninstall_subcom = com->add_subcommand(
"uninstall",
"Remove packages from active environment"
);
set_remove_command(uninstall_subcom, config);

CLI::App* list_subcom = com->add_subcommand("list", "List packages in active environment");
set_list_command(list_subcom, config);

Expand Down
39 changes: 39 additions & 0 deletions micromamba/tests/test_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,42 @@ def test_remove_config_target_prefix(
else:
res = helpers.remove(*cmd, "--print-config-only")
remove_config_common_assertions(res, root_prefix=r, target_prefix=p)


def test_uninstall(tmp_home, tmp_root_prefix, tmp_xtensor_env, tmp_env_name):
# Install xtensor and then uninstall xtensor the first time with the `remove`
# subcommand and a second time with the `uninstall` subcommand and check that
# their outputs are the same and that the environment is in the same state

res_list = helpers.umamba_list("-n", tmp_env_name, "--json")
n_packages_after_init = len(res_list)

# Install xtensor
helpers.install("xtensor", "-n", tmp_env_name, no_dry_run=True)

# Remove xtensor
res_remove = helpers.remove("xtensor", "-n", tmp_env_name, "--json")
assert res_remove["success"]
assert len(res_remove["actions"]["UNLINK"]) == 2
assert res_remove["actions"]["UNLINK"][0]["name"] == "xtensor"
assert res_remove["actions"]["UNLINK"][1]["name"] == "xtl"
assert res_remove["actions"]["PREFIX"] == str(tmp_xtensor_env)

# Check that the environment does not contain any packages
res_list = helpers.umamba_list("-n", tmp_env_name, "--json")
assert len(res_list) == n_packages_after_init

# Reinstall xtensor
helpers.install("xtensor", "-n", tmp_env_name, no_dry_run=True)

# Uninstall xtensor
res_uninstall = helpers.uninstall("xtensor", "-n", tmp_env_name, "--json")
assert res_uninstall["success"]
assert len(res_uninstall["actions"]["UNLINK"]) == 2
assert res_uninstall["actions"]["UNLINK"][0]["name"] == "xtensor"
assert res_uninstall["actions"]["UNLINK"][1]["name"] == "xtl"
assert res_uninstall["actions"]["PREFIX"] == str(tmp_xtensor_env)

# Check that the environment does not contain any packages
res_list = helpers.umamba_list("-n", tmp_env_name, "--json")
assert len(res_list) == n_packages_after_init

0 comments on commit 81ea936

Please sign in to comment.