diff --git a/test/libdnf5/module/test_module.cpp b/test/libdnf5/module/test_module.cpp index 4a3aa0ad2..e6ed6199e 100644 --- a/test/libdnf5/module/test_module.cpp +++ b/test/libdnf5/module/test_module.cpp @@ -675,6 +675,50 @@ void ModuleTest::test_module_enable() { } +void ModuleTest::test_module_enable_default() { + add_repo_repomd("repomd-modules"); + + // Add module enable goal operation + libdnf5::Goal goal(base); + goal.add_module_enable("NoStaticContext", libdnf5::GoalJobSettings()); + auto transaction = goal.resolve(); + + // Active modules contain the enabled NoStaticContext with its default stream latest, its dependency gooseberry + // and the default stream of module berries + std::vector expected_active_module_specs{ + "NoStaticContext:latest:1::x86_64", + "berries:main:4:6c81f848:x86_64", + "gooseberry:5.5:2:72aaf46b6:x86_64", + "gooseberry:5.5:3:72aaf46b6:x86_64"}; + std::vector 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); + + // Run the transaction + CPPUNIT_ASSERT_EQUAL(libdnf5::base::Transaction::TransactionRunResult::SUCCESS, transaction.run()); + + auto system_state = (base.*get(priv_impl()))->get_system_state(); + + // Module NoStaticContext is ENABLED because it was explicitly enabled + CPPUNIT_ASSERT_EQUAL( + libdnf5::system::ModuleState({"latest", ModuleStatus::ENABLED, {}}), + system_state.get_module_state("NoStaticContext")); + // Module goosebery is ENABLED because module NoStaticContext requires it + CPPUNIT_ASSERT_EQUAL( + libdnf5::system::ModuleState({"5.5", ModuleStatus::ENABLED, {}}), system_state.get_module_state("gooseberry")); + + // None of the other modules are ENABLED + for (auto [name, module_state] : system_state.get_module_states()) { + if (name != "NoStaticContext" && name != "gooseberry") { + CPPUNIT_ASSERT_EQUAL(libdnf5::system::ModuleState({"", ModuleStatus::AVAILABLE, {}}), module_state); + } + } +} + + void ModuleTest::test_module_disable() { add_repo_repomd("repomd-modules"); diff --git a/test/libdnf5/module/test_module.hpp b/test/libdnf5/module/test_module.hpp index a1b3a5c4d..1fc026c93 100644 --- a/test/libdnf5/module/test_module.hpp +++ b/test/libdnf5/module/test_module.hpp @@ -38,6 +38,7 @@ class ModuleTest : public BaseTestCase { CPPUNIT_TEST(test_query_spec); CPPUNIT_TEST(test_module_db); CPPUNIT_TEST(test_module_enable); + CPPUNIT_TEST(test_module_enable_default); CPPUNIT_TEST(test_module_disable); CPPUNIT_TEST(test_module_disable_enabled); CPPUNIT_TEST(test_module_reset); @@ -54,6 +55,7 @@ class ModuleTest : public BaseTestCase { void test_query_spec(); void test_module_db(); void test_module_enable(); + void test_module_enable_default(); void test_module_disable(); void test_module_disable_enabled(); void test_module_reset();