Skip to content

Commit

Permalink
Trivial: Merge two related unittest in dub package
Browse files Browse the repository at this point in the history
They both test computePackageSuppliers in the end.
  • Loading branch information
Geod24 authored and dlang-bot committed Dec 26, 2023
1 parent 58ecc1f commit 5dbe8cf
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions source/dub/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,6 @@ class Dub {
return result;
}

unittest
{
scope (exit) environment.remove("DUB_REGISTRY");
auto dub = new TestDub(".", null, SkipPackageSuppliers.configured);
assert(dub.m_packageSuppliers.length == 0);
environment["DUB_REGISTRY"] = "http://example.com/";
dub = new TestDub(".", null, SkipPackageSuppliers.configured);
assert(dub.m_packageSuppliers.length == 1);
environment["DUB_REGISTRY"] = "http://example.com/;http://foo.com/";
dub = new TestDub(".", null, SkipPackageSuppliers.configured);
assert(dub.m_packageSuppliers.length == 2);
dub = new TestDub(".", [new RegistryPackageSupplier(URL("http://bar.com/"))], SkipPackageSuppliers.configured);
assert(dub.m_packageSuppliers.length == 3);
}

/** Get the list of package suppliers.
Params:
Expand Down Expand Up @@ -352,27 +337,37 @@ class Dub {
return ps;
}

/// ditto
deprecated("This is an implementation detail. " ~
"Use `packageSuppliers` to get the computed list of package " ~
"suppliers once a `Dub` instance has been constructed.")
public PackageSupplier[] getPackageSuppliers(PackageSupplier[] additional_package_suppliers)
{
return getPackageSuppliers(additional_package_suppliers, m_config.skipRegistry);
}

unittest
{
auto dub = new TestDub();
scope (exit) environment.remove("DUB_REGISTRY");
auto dub = new TestDub(".", null, SkipPackageSuppliers.configured);
assert(dub.m_packageSuppliers.length == 0);
environment["DUB_REGISTRY"] = "http://example.com/";
dub = new TestDub(".", null, SkipPackageSuppliers.configured);
assert(dub.m_packageSuppliers.length == 1);
environment["DUB_REGISTRY"] = "http://example.com/;http://foo.com/";
dub = new TestDub(".", null, SkipPackageSuppliers.configured);
assert(dub.m_packageSuppliers.length == 2);
dub = new TestDub(".", [new RegistryPackageSupplier(URL("http://bar.com/"))], SkipPackageSuppliers.configured);
assert(dub.m_packageSuppliers.length == 3);

dub = new TestDub();
assert(dub.computePkgSuppliers(null, SkipPackageSuppliers.none, null).length == 1);
assert(dub.computePkgSuppliers(null, SkipPackageSuppliers.configured, null).length == 0);
assert(dub.computePkgSuppliers(null, SkipPackageSuppliers.standard, null).length == 0);

assert(dub.computePkgSuppliers(null, SkipPackageSuppliers.standard, "http://example.com/")
.length == 1);
}

/// ditto
deprecated("This is an implementation detail. " ~
"Use `packageSuppliers` to get the computed list of package " ~
"suppliers once a `Dub` instance has been constructed.")
public PackageSupplier[] getPackageSuppliers(PackageSupplier[] additional_package_suppliers)
{
return getPackageSuppliers(additional_package_suppliers, m_config.skipRegistry);
}

@property bool dryRun() const { return m_dryRun; }
@property void dryRun(bool v) { m_dryRun = v; }

Expand Down

0 comments on commit 5dbe8cf

Please sign in to comment.