Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test registry: Store version separate from Package #2871

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions source/dub/test/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ package class TestPackageManager : PackageManager
public class MockPackageSupplier : PackageSupplier
{
/// Mapping of package name to packages, ordered by `Version`
protected Package[][PackageName] pkgs;
protected Package[Version][PackageName] pkgs;

/// URL this was instantiated with
protected string url;
Expand All @@ -500,7 +500,7 @@ public class MockPackageSupplier : PackageSupplier
public override Version[] getVersions(in PackageName name)
{
if (auto ppkgs = name.main in this.pkgs)
return (*ppkgs).map!(pkg => pkg.version_).array;
return (*ppkgs).keys;
return null;
}

Expand All @@ -518,12 +518,14 @@ public class MockPackageSupplier : PackageSupplier
{
import dub.recipe.json;

Package match;
if (auto ppkgs = name.main in this.pkgs)
foreach_reverse (pkg; *ppkgs)
if ((!pkg.version_.isPreRelease || pre_release) &&
dep.matches(pkg.version_))
return toJson(pkg.recipe);
return Json.init;
foreach (vers, pkg; *ppkgs)
if ((!vers.isPreRelease || pre_release) &&
dep.matches(vers) &&
(match is null || match.version_ < vers))
match = pkg;
return match is null ? Json.init : toJson(match.recipe);
}

///
Expand Down
Loading