Skip to content

Commit

Permalink
Add test for subdir with rev
Browse files Browse the repository at this point in the history
  • Loading branch information
ashnair1 committed Apr 24, 2022
1 parent 75d3bcf commit 1cf9980
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
default_language_version:
python: python3.8

ci:
autofix_prs: false

Expand Down
24 changes: 22 additions & 2 deletions tests/console/commands/plugin/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


if TYPE_CHECKING:
from _pytest.fixtures import FixtureRequest
from cleo.testers.command_tester import CommandTester
from pytest_mock import MockerFixture

Expand Down Expand Up @@ -161,7 +162,17 @@ def test_add_with_git_constraint_with_extras(
)


@pytest.mark.parametrize(
"url",
[
"git+https://github.com/demo/poetry-plugin2.git#subdirectory=subdir",
"git+https://github.com/demo/poetry-plugin2.git@master#subdirectory=subdir",
],
ids=["norev", "rev"],
)
def test_add_with_git_constraint_with_subdirectory(
url: str,
request: FixtureRequest,
app: PoetryTestApplication,
repo: TestRepository,
tester: CommandTester,
Expand All @@ -170,7 +181,7 @@ def test_add_with_git_constraint_with_subdirectory(
):
repo.add_package(Package("pendulum", "2.0.5"))

tester.execute("git+https://github.com/demo/poetry-plugin2.git#subdirectory=subdir")
tester.execute(url)

expected = """\
Updating dependencies
Expand All @@ -184,12 +195,21 @@ def test_add_with_git_constraint_with_subdirectory(
• Installing poetry-plugin (0.1.2 9cf87a2)
"""

constraint = {
"git": "https://github.com/demo/poetry-plugin2.git",
"subdirectory": "subdir",
}

testid = request.node.callspec.id
if testid == "rev":
constraint["rev"] = "master"

assert_plugin_add_result(
tester,
app,
env,
expected,
{"git": "https://github.com/demo/poetry-plugin2.git", "subdirectory": "subdir"},
constraint,
)


Expand Down

0 comments on commit 1cf9980

Please sign in to comment.