Skip to content

Commit

Permalink
fix(cache clear): normalize package name
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Sep 16, 2022
1 parent 20352b6 commit d8c05c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/poetry/console/commands/cache/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from cleo.helpers import argument
from cleo.helpers import option
from packaging.utils import canonicalize_name

from poetry.config.config import Config
from poetry.console.commands.command import Command
Expand Down Expand Up @@ -66,7 +67,7 @@ def handle(self) -> int:
"Add a specific version to clear"
)
elif len(parts) == 3:
package = parts[1]
package = canonicalize_name(parts[1])
version = parts[2]

if not cache.has(f"{package}:{version}"):
Expand Down
6 changes: 5 additions & 1 deletion tests/console/commands/cache/test_clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ def test_cache_clear_all_no(
assert cache.has("cleo:0.2")


@pytest.mark.parametrize("package_name", ["cachy", "Cachy"])
def test_cache_clear_pkg(
tester: ApplicationTester,
repository_one: str,
cache: CacheManager,
package_name: str,
):
exit_code = tester.execute(f"cache clear {repository_one}:cachy:0.1", inputs="yes")
exit_code = tester.execute(
f"cache clear {repository_one}:{package_name}:0.1", inputs="yes"
)

assert exit_code == 0
assert tester.io.fetch_output() == ""
Expand Down

0 comments on commit d8c05c3

Please sign in to comment.