mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 10:55:46 -05:00
[libcalamares] Expand tests on Runner internals
This commit is contained in:
parent
e5fa58b890
commit
f0104af1c3
2 changed files with 49 additions and 1 deletions
|
@ -40,7 +40,7 @@ relativeChangeDirectory( QDir& directory, const QString& subdir )
|
|||
|
||||
|
||||
STATICTEST std::pair< bool, QDir >
|
||||
calculateWorkingDirectory( Calamares::Utils::RunLocation location, QString directory )
|
||||
calculateWorkingDirectory( Calamares::Utils::RunLocation location, const QString& directory )
|
||||
{
|
||||
Calamares::GlobalStorage* gs
|
||||
= Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "Entropy.h"
|
||||
#include "Logger.h"
|
||||
#include "RAII.h"
|
||||
#include "Runner.h"
|
||||
#include "String.h"
|
||||
#include "Traits.h"
|
||||
#include "UMask.h"
|
||||
|
@ -72,6 +73,7 @@ private Q_SLOTS:
|
|||
|
||||
/** @section Test Runner directory-manipulation. */
|
||||
void testRunnerDirs();
|
||||
void testCalculateWorkingDirectory();
|
||||
|
||||
private:
|
||||
void recursiveCompareMap( const QVariantMap& a, const QVariantMap& b, int depth );
|
||||
|
@ -836,6 +838,52 @@ LibCalamaresTests::testRunnerDirs()
|
|||
}
|
||||
}
|
||||
|
||||
// Method under test
|
||||
extern std::pair< bool, QDir > calculateWorkingDirectory( Calamares::Utils::RunLocation location,
|
||||
const QString& directory );
|
||||
|
||||
void
|
||||
LibCalamaresTests::testCalculateWorkingDirectory()
|
||||
{
|
||||
Calamares::GlobalStorage* gs
|
||||
= Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
||||
|
||||
if ( !gs )
|
||||
{
|
||||
cDebug() << "Creating new JobQueue";
|
||||
(void)new Calamares::JobQueue();
|
||||
gs = Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
||||
}
|
||||
QVERIFY( gs );
|
||||
|
||||
// Working with a rootMountPoint set
|
||||
QTemporaryDir tempRoot( QDir::tempPath() + QStringLiteral( "/test-job-XXXXXX" ) );
|
||||
gs->insert( "rootMountPoint", tempRoot.path() );
|
||||
|
||||
{
|
||||
auto [ ok, d ] = calculateWorkingDirectory( CalamaresUtils::System::RunLocation::RunInHost, QString() );
|
||||
QVERIFY( ok );
|
||||
QCOMPARE( d, QDir::current() );
|
||||
}
|
||||
{
|
||||
auto [ ok, d ] = calculateWorkingDirectory( CalamaresUtils::System::RunLocation::RunInTarget, QString() );
|
||||
QVERIFY( ok );
|
||||
QCOMPARE( d.absolutePath(), tempRoot.path() );
|
||||
}
|
||||
|
||||
gs->remove( "rootMountPoint" );
|
||||
{
|
||||
auto [ ok, d ] = calculateWorkingDirectory( CalamaresUtils::System::RunLocation::RunInHost, QString() );
|
||||
QVERIFY( ok );
|
||||
QCOMPARE( d, QDir::current() );
|
||||
}
|
||||
{
|
||||
auto [ ok, d ] = calculateWorkingDirectory( CalamaresUtils::System::RunLocation::RunInTarget, QString() );
|
||||
QVERIFY( !ok );
|
||||
QCOMPARE( d, QDir::current() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QTEST_GUILESS_MAIN( LibCalamaresTests )
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue