Commit 8ef2a645 by Ashwin Nair Committed by Randy Döring

Add tests for git urls with subdirectory

parent 49b1fb29
......@@ -138,6 +138,53 @@ Package operations: 3 installs, 0 updates, 0 removals
)
@pytest.mark.parametrize(
"url, rev",
[
("git+https://github.com/demo/poetry-plugin2.git#subdirectory=subdir", None),
(
"git+https://github.com/demo/poetry-plugin2.git@master#subdirectory=subdir",
"master",
),
],
)
def test_add_with_git_constraint_with_subdirectory(
url: str,
rev: str | None,
tester: CommandTester,
repo: TestRepository,
):
repo.add_package(Package("pendulum", "2.0.5"))
tester.execute(url)
expected = """
Updating dependencies
Resolving dependencies...
Writing lock file
Package operations: 2 installs, 0 updates, 0 removals
• Installing pendulum (2.0.5)
• Installing poetry-plugin (0.1.2 9cf87a2)
"""
constraint = {
"git": "https://github.com/demo/poetry-plugin2.git",
"subdirectory": "subdir",
}
if rev:
constraint["rev"] = rev
assert_plugin_add_result(
tester,
expected,
constraint,
)
def test_add_existing_plugin_warns_about_no_operation(
tester: CommandTester,
repo: TestRepository,
......
......@@ -374,6 +374,53 @@ Package operations: 4 installs, 0 updates, 0 removals
}
@pytest.mark.parametrize(
"url, rev",
[
("git+https://github.com/demo/subdirectories.git#subdirectory=two", None),
(
"git+https://github.com/demo/subdirectories.git@master#subdirectory=two",
"master",
),
],
)
def test_add_git_constraint_with_subdirectory(
url: str,
rev: str | None,
app: PoetryTestApplication,
repo: TestRepository,
tester: CommandTester,
env: MockEnv,
):
tester.execute(url)
expected = """\
Updating dependencies
Resolving dependencies...
Writing lock file
Package operations: 1 install, 0 updates, 0 removals
• Installing two (2.0.0 9cf87a2)
"""
assert tester.io.fetch_output().strip() == expected.strip()
assert tester.command.installer.executor.installations_count == 1
content = app.poetry.file.read()["tool"]["poetry"]
constraint = {
"git": "https://github.com/demo/subdirectories.git",
"subdirectory": "two",
}
if rev:
constraint["rev"] = rev
assert "two" in content["dependencies"]
assert content["dependencies"]["two"] == constraint
@pytest.mark.parametrize("editable", [False, True])
def test_add_git_ssh_constraint(
editable: bool,
......
[tool.poetry]
name = "poetry-plugin"
version = "0.1.2"
description = "Some description."
authors = [
"Sébastien Eustace <sebastien@eustace.io>"
]
license = "MIT"
[tool.poetry.dependencies]
python = "^3.6"
pendulum = "^2.0"
tomlkit = {version = "^0.7.0", optional = true}
[tool.poetry.extras]
foo = ["tomlkit"]
[tool.poetry.dev-dependencies]
......@@ -6,4 +6,4 @@ authors = []
license = "MIT"
[tool.poetry.dependencies]
python = "^3.7"
python = "~2.7 || ^3.4"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment