Skip to content

Commit

Permalink
test(installer): use locked version of vcs dependency without referen…
Browse files Browse the repository at this point in the history
…ce (branch, tag, rev) instead of latest

Requires: python-poetry/poetry-core#449
  • Loading branch information
radoering committed Aug 27, 2022
1 parent a4d4cad commit c55d5ac
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/installation/fixtures/with-vcs-dependency-without-ref.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[[package]]
name = "demo"
version = "0.1.2"
description = ""
category = "main"
optional = false
python-versions = "*"
develop = false

[package.dependencies]
pendulum = ">=1.4.4"

[package.source]
type = "git"
url = "https://github.com/demo/demo.git"
reference = "HEAD"
resolved_reference = "123456"

[[package]]
name = "pendulum"
version = "1.4.4"
description = ""
category = "main"
optional = false
python-versions = "*"

[metadata]
python-versions = "*"
lock-version = "1.1"
content-hash = "123456789"

[metadata.files]
demo = []
pendulum = []
38 changes: 38 additions & 0 deletions tests/installation/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2516,3 +2516,41 @@ def test_installer_should_use_the_locked_version_of_git_dependencies_with_extras
source_reference="master",
source_resolved_reference=expected_reference,
)


@pytest.mark.parametrize("is_locked", [False, True])
def test_installer_should_use_the_locked_version_of_git_dependencies_without_reference(
installer: Installer,
locker: Locker,
package: ProjectPackage,
repo: Repository,
is_locked: bool,
):
"""
If there is no explicit reference (branch or tag or rev) in pyproject.toml,
HEAD is used.
"""
if is_locked:
locker.locked(True)
locker.mock_lock_data(fixture("with-vcs-dependency-without-ref"))
expected_reference = "123456"
else:
expected_reference = MOCK_DEFAULT_GIT_REVISION

package.add_dependency(
Factory.create_dependency("demo", {"git": "https://github.com/demo/demo.git"})
)

repo.add_package(get_package("pendulum", "1.4.4"))

installer.run()

assert len(installer.executor.installations) == 2
assert installer.executor.installations[-1] == Package(
"demo",
"0.1.2",
source_type="git",
source_url="https://github.com/demo/demo.git",
source_reference="HEAD",
source_resolved_reference=expected_reference,
)

0 comments on commit c55d5ac

Please sign in to comment.