[libcalamares] Expand tests a little
- do some additions and check they work - drop the ";add" annotation on the source, this is not needed in the current situation with only adds available.
This commit is contained in:
parent
5b609565e2
commit
f1446736f8
@ -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
|
||||
|
@ -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 )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user