-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use correct
url
in metadata and mirrors (#3816)
- Loading branch information
Showing
8 changed files
with
164 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright (c) 2025, QuantStack and Mamba Contributors | ||
// | ||
// Distributed under the terms of the BSD 3-Clause License. | ||
// | ||
// The full license is in the file LICENSE, distributed with this software. | ||
|
||
#include <catch2/catch_all.hpp> | ||
|
||
#include "mamba/core/context.hpp" | ||
#include "mamba/core/package_fetcher.hpp" | ||
|
||
namespace | ||
{ | ||
using namespace mamba; | ||
|
||
TEST_CASE("build_download_request") | ||
{ | ||
auto ctx = Context(); | ||
MultiPackageCache package_caches{ ctx.pkgs_dirs, ctx.validation_params }; | ||
|
||
SECTION("From conda-forge") | ||
{ | ||
static constexpr std::string_view url = "https://conda.anaconda.org/conda-forge/linux-64/pkg-6.4-bld.conda"; | ||
auto pkg_info = specs::PackageInfo::from_url(url).value(); | ||
|
||
PackageFetcher pkg_fetcher{ pkg_info, package_caches }; | ||
REQUIRE(pkg_fetcher.name() == pkg_info.name); | ||
|
||
auto req = pkg_fetcher.build_download_request(); | ||
// Should correspond to package name | ||
REQUIRE(req.name == pkg_info.name); | ||
// Should correspond to PackageFetcher::channel() | ||
REQUIRE(req.mirror_name == ""); | ||
// Should correspond to PackageFetcher::url_path() | ||
REQUIRE(req.url_path == url); | ||
} | ||
|
||
SECTION("From some mirror") | ||
{ | ||
static constexpr std::string_view url = "https://repo.prefix.dev/emscripten-forge-dev/emscripten-wasm32/cpp-tabulate-1.5.0-h7223423_2.tar.bz2"; | ||
auto pkg_info = specs::PackageInfo::from_url(url).value(); | ||
|
||
PackageFetcher pkg_fetcher{ pkg_info, package_caches }; | ||
REQUIRE(pkg_fetcher.name() == pkg_info.name); | ||
|
||
auto req = pkg_fetcher.build_download_request(); | ||
// Should correspond to package name | ||
REQUIRE(req.name == pkg_info.name); | ||
// Should correspond to PackageFetcher::channel() | ||
REQUIRE(req.mirror_name == ""); | ||
// Should correspond to PackageFetcher::url_path() | ||
REQUIRE(req.url_path == url); | ||
} | ||
|
||
SECTION("From local file") | ||
{ | ||
static constexpr std::string_view url = "file:///home/wolfv/Downloads/xtensor-0.21.4-hc9558a2_0.tar.bz2"; | ||
auto pkg_info = specs::PackageInfo::from_url(url).value(); | ||
|
||
PackageFetcher pkg_fetcher{ pkg_info, package_caches }; | ||
REQUIRE(pkg_fetcher.name() == pkg_info.name); | ||
|
||
auto req = pkg_fetcher.build_download_request(); | ||
// Should correspond to package name | ||
REQUIRE(req.name == pkg_info.name); | ||
// Should correspond to PackageFetcher::channel() | ||
REQUIRE(req.mirror_name == ""); | ||
// Should correspond to PackageFetcher::url_path() | ||
REQUIRE(req.url_path == url); | ||
} | ||
|
||
SECTION("From oci") | ||
{ | ||
static constexpr std::string_view url = "oci://ghcr.io/channel-mirrors/conda-forge/linux-64/xtensor-0.25.0-h00ab1b0_0.conda"; | ||
auto pkg_info = specs::PackageInfo::from_url(url).value(); | ||
|
||
PackageFetcher pkg_fetcher{ pkg_info, package_caches }; | ||
REQUIRE(pkg_fetcher.name() == pkg_info.name); | ||
|
||
auto req = pkg_fetcher.build_download_request(); | ||
// Should correspond to package name | ||
REQUIRE(req.name == pkg_info.name); | ||
// Should correspond to PackageFetcher::channel() | ||
REQUIRE(req.mirror_name == "oci://ghcr.io/channel-mirrors/conda-forge"); | ||
// Should correspond to PackageFetcher::url_path() | ||
REQUIRE(req.url_path == "linux-64/xtensor-0.25.0-h00ab1b0_0.conda"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters