[libcalamares] Add some tests for CreationResult
- More important is the compiler warning that will show up if we add more failure states.
This commit is contained in:
parent
274115c727
commit
f6526f7d9f
@ -46,6 +46,7 @@ private Q_SLOTS:
|
||||
void init();
|
||||
void cleanupTestCase();
|
||||
|
||||
void testCreationResult();
|
||||
void testTargetPath();
|
||||
void testCreateTarget();
|
||||
void testCreateTargetBasedirs();
|
||||
@ -95,6 +96,42 @@ TestPaths::init()
|
||||
m_gs->insert( "rootMountPoint", "/tmp" );
|
||||
}
|
||||
|
||||
void TestPaths::testCreationResult()
|
||||
{
|
||||
using Code = CalamaresUtils::CreationResult::Code;
|
||||
|
||||
for( auto c : { Code::OK, Code::AlreadyExists, Code::Failed, Code::Invalid } )
|
||||
{
|
||||
auto r = CalamaresUtils::CreationResult( c );
|
||||
QVERIFY( r.path().isEmpty() );
|
||||
QCOMPARE( r.path(), QString() );
|
||||
// Get a warning from Clang if we're not covering everything
|
||||
switch( r.code() )
|
||||
{
|
||||
case Code::OK:
|
||||
QVERIFY( !r.failed() );
|
||||
QVERIFY( r );
|
||||
break;
|
||||
case Code::AlreadyExists:
|
||||
QVERIFY( !r.failed() );
|
||||
QVERIFY( !r );
|
||||
break;
|
||||
case Code::Failed:
|
||||
case Code::Invalid:
|
||||
QVERIFY( r.failed() );
|
||||
QVERIFY( !r );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString path( "/etc/os-release" );
|
||||
auto r = CalamaresUtils::CreationResult( path );
|
||||
QVERIFY( !r.failed() );
|
||||
QVERIFY( r );
|
||||
QCOMPARE( r.code(), Code::OK );
|
||||
QCOMPARE( r.path(), path );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TestPaths::testTargetPath()
|
||||
|
Loading…
Reference in New Issue
Block a user