[libcalamares] Make Packages API more flexible
- pass in the GS object; this makes mostly **testing** much easier
This commit is contained in:
parent
b868894371
commit
5b609565e2
@ -10,11 +10,11 @@
|
||||
#include "Globals.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
bool
|
||||
CalamaresUtils::Packages::setGSPackageAdditions( const Calamares::ModuleSystem::InstanceKey& module,
|
||||
CalamaresUtils::Packages::setGSPackageAdditions( Calamares::GlobalStorage* gs,
|
||||
const Calamares::ModuleSystem::InstanceKey& module,
|
||||
const QVariantList& installPackages,
|
||||
const QVariantList& tryInstallPackages )
|
||||
{
|
||||
@ -22,7 +22,6 @@ CalamaresUtils::Packages::setGSPackageAdditions( const Calamares::ModuleSystem::
|
||||
|
||||
// Check if there's already a PACAKGEOP entry in GS, and if so we'll
|
||||
// extend that one (overwriting the value in GS at the end of this method)
|
||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
QVariantList packageOperations = gs->contains( PACKAGEOP ) ? gs->value( PACKAGEOP ).toList() : QVariantList();
|
||||
cDebug() << "Existing package operations length" << packageOperations.length();
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#ifndef LIBCALAMARES_PACKAGES_GLOBALS_H
|
||||
#define LIBCALAMARES_PACKAGES_GLOBALS_H
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "modulesystem/InstanceKey.h"
|
||||
|
||||
namespace CalamaresUtils
|
||||
@ -20,8 +21,11 @@ namespace Packages
|
||||
*
|
||||
* This replaces previously-set install-packages lists for the
|
||||
* given module by the two new lists.
|
||||
*
|
||||
* Returns @c true if anything was changed, @c false otherwise.
|
||||
*/
|
||||
bool setGSPackageAdditions( const Calamares::ModuleSystem::InstanceKey& module,
|
||||
bool setGSPackageAdditions( Calamares::GlobalStorage* gs,
|
||||
const Calamares::ModuleSystem::InstanceKey& module,
|
||||
const QVariantList& installPackages,
|
||||
const QVariantList& tryInstallPackages );
|
||||
// void setGSPackageRemovals( const Calamares::ModuleSystem::InstanceKey& key, const QVariantList& removePackages );
|
||||
|
@ -7,9 +7,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "utils/Logger.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
@ -34,6 +35,16 @@ PackagesTests::initTestCase()
|
||||
void
|
||||
PackagesTests::testEmpty()
|
||||
{
|
||||
Calamares::GlobalStorage gs;
|
||||
const QString topKey( "packageOperations" );
|
||||
Calamares::ModuleSystem::InstanceKey k( "this", "that" );
|
||||
|
||||
QVERIFY( !gs.contains( topKey ) );
|
||||
QCOMPARE( k.toString(), "this@that" );
|
||||
|
||||
// Adding nothing at all does nothing
|
||||
QVERIFY( !CalamaresUtils::Packages::setGSPackageAdditions( &gs, k, QVariantList(), QVariantList() ) );
|
||||
QVERIFY( !gs.contains( topKey ) );
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user