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

Trivial: Merge two related unittest in dub package #2756

Merged
merged 1 commit into from
Dec 26, 2023
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
47 changes: 21 additions & 26 deletions source/dub/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,6 @@ class Dub {
}
}

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 @@ -338,27 +323,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
Loading