Skip to content

Commit

Permalink
Switch the order of LockMeta's being merged so that other takes pre…
Browse files Browse the repository at this point in the history
…cedence over `self`
  • Loading branch information
jeffseif committed Mar 13, 2024
1 parent 4448144 commit b42fa14
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conda_lock/lockfile/v2prelim/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def merge(self, other: "Optional[Lockfile]") -> "Lockfile":

# Resort the conda packages topologically
final_package = self._toposort(package)
return Lockfile(package=final_package, metadata=other.metadata | self.metadata)
return Lockfile(package=final_package, metadata=self.metadata | other.metadata)

def toposort_inplace(self) -> None:
self.package = self._toposort(self.package)
Expand Down
27 changes: 27 additions & 0 deletions tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2729,3 +2729,30 @@ def test_pip_full_whl_url(
typing_extensions_dep.hash.sha256
== "8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0"
)


def test_when_merging_lockfiles_content_hashes_are_updated(
conda_exe: str,
monkeypatch: "pytest.MonkeyPatch",
tmp_path: Path,
):
work_path = clone_test_dir(name="test-update", tmp_path=tmp_path)
monkeypatch.chdir(work_path)
run_lock(
environment_files=[work_path / "environment-preupdate.yml"],
conda_exe=str(conda_exe),
platforms=["linux-64"],
)

def get_content_hashes_for_lock_file(lock_file: Path) -> dict[str, str]:
lock_file_dict = yaml.safe_load(lock_file.read_text())
return lock_file_dict["metadata"]["content_hash"]

preupdate_hashes = get_content_hashes_for_lock_file(work_path / "conda-lock.yml")
run_lock(
environment_files=[work_path / "environment-postupdate.yml"],
conda_exe=str(conda_exe),
platforms=["linux-64"],
)
postupdate_hashes = get_content_hashes_for_lock_file(work_path / "conda-lock.yml")
assert preupdate_hashes != postupdate_hashes

0 comments on commit b42fa14

Please sign in to comment.