Skip to content

Commit

Permalink
Code review: add comment and use vars in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hind-M committed Feb 20, 2025
1 parent 09c8f32 commit 9d15db7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
27 changes: 11 additions & 16 deletions libmamba/tests/src/core/test_package_fetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ namespace
auto pkg_info = specs::PackageInfo::from_url(url).value();

PackageFetcher pkg_fetcher{ pkg_info, package_caches };
REQUIRE(pkg_fetcher.name() == "pkg");
REQUIRE(pkg_fetcher.name() == pkg_info.name);

auto req = pkg_fetcher.build_download_request();
// Should correspond to package name
REQUIRE(req.name == "pkg");
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 == "https://conda.anaconda.org/conda-forge/linux-64/pkg-6.4-bld.conda"
);
REQUIRE(req.url_path == url);
}

SECTION("From some mirror")
Expand All @@ -43,18 +41,15 @@ namespace
auto pkg_info = specs::PackageInfo::from_url(url).value();

PackageFetcher pkg_fetcher{ pkg_info, package_caches };
REQUIRE(pkg_fetcher.name() == "cpp-tabulate");
REQUIRE(pkg_fetcher.name() == pkg_info.name);

auto req = pkg_fetcher.build_download_request();
// Should correspond to package name
REQUIRE(req.name == "cpp-tabulate");
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
== "https://repo.prefix.dev/emscripten-forge-dev/emscripten-wasm32/cpp-tabulate-1.5.0-h7223423_2.tar.bz2"
);
REQUIRE(req.url_path == url);
}

SECTION("From local file")
Expand All @@ -63,15 +58,15 @@ namespace
auto pkg_info = specs::PackageInfo::from_url(url).value();

PackageFetcher pkg_fetcher{ pkg_info, package_caches };
REQUIRE(pkg_fetcher.name() == "xtensor");
REQUIRE(pkg_fetcher.name() == pkg_info.name);

auto req = pkg_fetcher.build_download_request();
// Should correspond to package name
REQUIRE(req.name == "xtensor");
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 == "file:///home/wolfv/Downloads/xtensor-0.21.4-hc9558a2_0.tar.bz2");
REQUIRE(req.url_path == url);
}

SECTION("From oci")
Expand All @@ -80,11 +75,11 @@ namespace
auto pkg_info = specs::PackageInfo::from_url(url).value();

PackageFetcher pkg_fetcher{ pkg_info, package_caches };
REQUIRE(pkg_fetcher.name() == "xtensor");
REQUIRE(pkg_fetcher.name() == pkg_info.name);

auto req = pkg_fetcher.build_download_request();
// Should correspond to package name
REQUIRE(req.name == "xtensor");
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()
Expand Down
5 changes: 4 additions & 1 deletion micromamba/tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,10 @@ def test_create_with_explicit_url(tmp_home, tmp_root_prefix, spec):


def test_create_from_mirror(tmp_home, tmp_root_prefix):
"""Attempts to install a package using an explicit channel/mirror."""
"""
Attempts to install a package using an explicit channel/mirror.
Non-regression test for https://github.com/mamba-org/mamba/issues/3804
"""
env_name = "env-create-from-mirror"

res = helpers.create(
Expand Down

0 comments on commit 9d15db7

Please sign in to comment.