[libcalamares] Update tests to reflect changed API

This commit is contained in:
Adriaan de Groot 2020-02-14 13:07:29 +01:00
parent 2d7398161d
commit 274115c727
4 changed files with 27 additions and 13 deletions

View File

@ -117,7 +117,10 @@ TestPaths::testTargetPath()
void
TestPaths::testCreateTarget()
{
QCOMPARE( m_system->createTargetFile( testFile, "Hello" ), QString( absFile ) ); // Success
auto r = m_system->createTargetFile( testFile, "Hello" );
QVERIFY( !r.failed() );
QVERIFY( r );
QCOMPARE( r.path(), QString( absFile ) ); // Success
QFileInfo fi( absFile );
QVERIFY( fi.exists() );

View File

@ -54,7 +54,7 @@ InitramfsJob::exec()
// First make sure we generate a safe initramfs with suitable permissions.
static const char confFile[] = "/etc/initramfs-tools/conf.d/calamares-safe-initramfs.conf";
static const char contents[] = "UMASK=0077\n";
if ( CalamaresUtils::System::instance()->createTargetFile( confFile, QByteArray( contents ) ).isEmpty() )
if ( CalamaresUtils::System::instance()->createTargetFile( confFile, QByteArray( contents ) ).failed() )
{
cWarning() << Logger::SubEntry << "Could not configure safe UMASK for initramfs.";
// But continue anyway.

View File

@ -59,7 +59,10 @@ void InitramfsTests::testCreateHostFile()
{
CalamaresUtils::System s( false ); // don't chroot
QString path = s.createTargetFile( confFile, QByteArray( contents ) );
auto r = s.createTargetFile( confFile, QByteArray( contents ) );
QVERIFY( !r.failed() );
QVERIFY( r );
QString path = r.path();
QVERIFY( !path.isEmpty() );
QCOMPARE( path, confFile ); // don't chroot, so path create relative to /
QVERIFY( QFile::exists( confFile ) );
@ -76,7 +79,10 @@ void InitramfsTests::testCreateTargetFile()
static const char short_confFile[] = "/calamares-safe-umask";
CalamaresUtils::System s( true );
QString path = s.createTargetFile( short_confFile, QByteArray( contents ) );
auto r = s.createTargetFile( short_confFile, QByteArray( contents ) );
QVERIFY( r.failed() );
QVERIFY( !r );
QString path = r.path();
QVERIFY( path.isEmpty() ); // because no rootmountpoint is set
Calamares::JobQueue j;

View File

@ -122,8 +122,13 @@ MachineIdTests::testJob()
gs->insert( "rootMountPoint", "/tmp" );
// Prepare part of the target filesystem
{
QVERIFY( system->createTargetDirs("/etc") );
QVERIFY( !(system->createTargetFile( "/etc/machine-id", "Hello" ).isEmpty() ) );
auto r = system->createTargetFile( "/etc/machine-id", "Hello" );
QVERIFY( !r.failed() );
QVERIFY( r );
QVERIFY( !r.path().isEmpty() );
}
MachineIdJob job( nullptr );
QVERIFY( !job.prettyName().isEmpty() );