Skip to content

Commit

Permalink
modules: Test globs in module_spec argument in `Goal::add_module_enab…
Browse files Browse the repository at this point in the history
…le()`
  • Loading branch information
pkratoch authored and ppisar committed Nov 10, 2023
1 parent b9e220f commit 029455f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
17 changes: 17 additions & 0 deletions test/data/repos-repomd/repomd-modules/repodata/modules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,23 @@ data:
- requires:
gooseberry: [5.6]
...
---
document: modulemd
version: 2
data:
name: vegetable-salad
stream: latest
version: 1
context: aaa456b
arch: x86_64
summary: Test module
description: Test module
license:
module: [MIT]
profiles:
minimal:
rpms: []
...
---
document: modulemd
version: 2
Expand Down
4 changes: 2 additions & 2 deletions test/data/repos-repomd/repomd-modules/repodata/repomd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<open-size>864433</open-size>
</data>
<data type="modules">
<checksum type="sha256">110f14b601219ff369b024eba2a96d65efb5675e2bdbb84cabf644529ebd44ee</checksum>
<open-checksum type="sha256">110f14b601219ff369b024eba2a96d65efb5675e2bdbb84cabf644529ebd44ee</open-checksum>
<checksum type="sha256">3afb8a29deb024cf0bfecf0623d1a0feb11d0ca77e4564f5137cbd3fd91a718a</checksum>
<open-checksum type="sha256">3afb8a29deb024cf0bfecf0623d1a0feb11d0ca77e4564f5137cbd3fd91a718a</open-checksum>
<location href="repodata/modules.yaml" />
<timestamp>1641802880</timestamp>
<size>492</size>
Expand Down
33 changes: 29 additions & 4 deletions test/libdnf5/module/test_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void ModuleTest::test_load() {
add_repo_repomd("repomd-modules");

auto module_sack = base.get_module_sack();
CPPUNIT_ASSERT_EQUAL((size_t)10, module_sack->get_modules().size());
CPPUNIT_ASSERT_EQUAL((size_t)11, module_sack->get_modules().size());

ModuleQuery query = ModuleQuery(base, false);
query.filter_name("meson");
Expand Down Expand Up @@ -197,7 +197,7 @@ void ModuleTest::test_query_latest() {

{ // Check we can see all the modules, even ones with duplicit nscva
ModuleQuery query(base, false);
CPPUNIT_ASSERT_EQUAL((size_t)13, query.size());
CPPUNIT_ASSERT_EQUAL((size_t)14, query.size());
}

{
Expand All @@ -209,13 +209,13 @@ void ModuleTest::test_query_latest() {
{
ModuleQuery query(base, false);
query.filter_latest();
CPPUNIT_ASSERT_EQUAL((size_t)11, query.size());
CPPUNIT_ASSERT_EQUAL((size_t)12, query.size());
}

{
ModuleQuery query(base, false);
query.filter_latest(-1);
CPPUNIT_ASSERT_EQUAL((size_t)10, query.size());
CPPUNIT_ASSERT_EQUAL((size_t)11, query.size());
}

{
Expand Down Expand Up @@ -776,3 +776,28 @@ void ModuleTest::test_module_reset() {
CPPUNIT_ASSERT_EQUAL(libdnf5::system::ModuleState({"", ModuleStatus::AVAILABLE, {}}), module_state);
}
}


void ModuleTest::test_module_globs() {
add_repo_repomd("repomd-modules");

// Add module enable goal operation with module_spec containing globs
libdnf5::Goal goal(base);
goal.add_module_enable("*salad", libdnf5::GoalJobSettings());
auto transaction = goal.resolve();

// Active modules contain the enabled fruit-salad and vegetable-salad, its dependency gooseberry and the default
// stream of module berries
std::vector<std::string> expected_active_module_specs{
"berries:main:4:6c81f848:x86_64",
"fruit-salad:main:12:2241675a:x86_64",
"gooseberry:5.5:2:72aaf46b6:x86_64",
"gooseberry:5.5:3:72aaf46b6:x86_64",
"vegetable-salad:latest:1:aaa456b:x86_64"};
std::vector<std::string> active_module_specs;
for (auto & module_item : base.get_module_sack()->get_active_modules()) {
active_module_specs.push_back(module_item->get_full_identifier());
}
std::sort(active_module_specs.begin(), active_module_specs.end());
CPPUNIT_ASSERT_EQUAL(expected_active_module_specs, active_module_specs);
}
2 changes: 2 additions & 0 deletions test/libdnf5/module/test_module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ModuleTest : public BaseTestCase {
CPPUNIT_TEST(test_module_disable);
CPPUNIT_TEST(test_module_disable_enabled);
CPPUNIT_TEST(test_module_reset);
CPPUNIT_TEST(test_module_globs);
CPPUNIT_TEST_SUITE_END();

public:
Expand All @@ -56,6 +57,7 @@ class ModuleTest : public BaseTestCase {
void test_module_disable();
void test_module_disable_enabled();
void test_module_reset();
void test_module_globs();

std::unique_ptr<libdnf5::utils::fs::TempDir> temp_dir;
};
Expand Down

0 comments on commit 029455f

Please sign in to comment.