Skip to content

Commit

Permalink
Fix behavior when base_url is missing with repodata_version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Hind-M committed May 27, 2024
1 parent 7b61593 commit 420b74e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
6 changes: 0 additions & 6 deletions libmamba/src/solver/libsolv/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,6 @@ namespace mamba::solver::libsolv
{
base_url = std::string(url.value_unsafe());
}
else
{
throw std::invalid_argument(
"'info/base_url' not found in repodata.json file while 'repodata_version': 2"
);
}
}
}

Expand Down
38 changes: 29 additions & 9 deletions libmamba/tests/src/solver/libsolv/test_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,35 @@ TEST_SUITE("solver::libsolv::database")
{
const auto repodata = mambatests::test_data_dir
/ "repodata/conda-forge-repodata-version-2-missing-base_url.json";
CHECK_THROWS_AS(
db.add_repo_from_repodata_json(
repodata,
"https://conda.anaconda.org/conda-forge/linux-64",
"conda-forge",
libsolv::PipAsPythonDependency::No,
libsolv::PackageTypes::CondaOrElseTarBz2
),
std::invalid_argument
auto repo1 = db.add_repo_from_repodata_json(
repodata,
"https://conda.anaconda.org/conda-forge/linux-64",
"conda-forge",
libsolv::PipAsPythonDependency::No,
libsolv::PackageTypes::CondaOrElseTarBz2
);
REQUIRE(repo1.has_value());
CHECK_EQ(repo1->package_count(), 2);

db.for_each_package_in_repo(
repo1.value(),
[&](const auto& p)
{
if (p.name == "_libgcc_mutex")
{
CHECK_EQ(
p.package_url,
"https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2"
);
}
else if (p.name == "bzip2")
{
CHECK_EQ(
p.package_url,
"https://conda.anaconda.org/conda-forge/linux-64/bzip2-1.0.8-hd590300_5.conda"
);
}
}
);
}
}
Expand Down

0 comments on commit 420b74e

Please sign in to comment.