diff --git a/src/libcalamares/packages/Globals.cpp b/src/libcalamares/packages/Globals.cpp index 6cd07bc4a..c5e882436 100644 --- a/src/libcalamares/packages/Globals.cpp +++ b/src/libcalamares/packages/Globals.cpp @@ -25,7 +25,7 @@ CalamaresUtils::Packages::setGSPackageAdditions( Calamares::GlobalStorage* gs, QVariantList packageOperations = gs->contains( PACKAGEOP ) ? gs->value( PACKAGEOP ).toList() : QVariantList(); cDebug() << "Existing package operations length" << packageOperations.length(); - const QString key = module.toString() + QStringLiteral( ";add" ); + const QString key = module.toString(); // Clear out existing operations for this module, going backwards: // Sometimes we remove an item, and we don't want the index to diff --git a/src/libcalamares/packages/Tests.cpp b/src/libcalamares/packages/Tests.cpp index aaff227a9..0a9be3a20 100644 --- a/src/libcalamares/packages/Tests.cpp +++ b/src/libcalamares/packages/Tests.cpp @@ -24,6 +24,7 @@ private Q_SLOTS: void initTestCase(); void testEmpty(); + void testAdd(); }; void @@ -47,6 +48,38 @@ PackagesTests::testEmpty() QVERIFY( !gs.contains( topKey ) ); } +void +PackagesTests::testAdd() +{ + Calamares::GlobalStorage gs; + const QString topKey( "packageOperations" ); + Calamares::ModuleSystem::InstanceKey k( "this", "that" ); + + QVERIFY( !gs.contains( topKey ) ); + QVERIFY( + CalamaresUtils::Packages::setGSPackageAdditions( &gs, k, QVariantList { QString( "vim" ) }, QVariantList() ) ); + QVERIFY( gs.contains( topKey ) ); + auto actionList = gs.value( topKey ).toList(); + QCOMPARE( actionList.length(), 1 ); + auto action = actionList[ 0 ].toMap(); + QVERIFY( action.contains( "install" ) ); + auto op = action[ "install" ].toList(); + QCOMPARE( op.length(), 1 ); + cDebug() << op; + + QVERIFY( CalamaresUtils::Packages::setGSPackageAdditions( + &gs, k, QVariantList { QString( "vim" ), QString( "emacs" ) }, QVariantList() ) ); + QVERIFY( gs.contains( topKey ) ); + actionList = gs.value( topKey ).toList(); + QCOMPARE( actionList.length(), 1 ); + action = actionList[ 0 ].toMap(); + QVERIFY( action.contains( "install" ) ); + op = action[ "install" ].toList(); + QCOMPARE( op.length(), 2 ); + QCOMPARE( action[ "source" ].toString(), k.toString() ); + cDebug() << op; +} + QTEST_GUILESS_MAIN( PackagesTests )