[users] Test the moved setHostname Config
- document that the default for writeHostsFile is *true*
This commit is contained in:
parent
2efce1ac7a
commit
fcafe5db8f
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
// Implementation details
|
// Implementation details
|
||||||
extern void setConfigurationDefaultGroups( const QVariantMap& map, QStringList& defaultGroups );
|
extern void setConfigurationDefaultGroups( const QVariantMap& map, QStringList& defaultGroups );
|
||||||
|
extern HostNameActions getHostNameActions( const QVariantMap& configurationMap );
|
||||||
|
|
||||||
/** @brief Test Config object methods and internals
|
/** @brief Test Config object methods and internals
|
||||||
*
|
*
|
||||||
@ -40,6 +41,8 @@ private Q_SLOTS:
|
|||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
|
||||||
void testDefaultGroups();
|
void testDefaultGroups();
|
||||||
|
void testHostActions_data();
|
||||||
|
void testHostActions();
|
||||||
};
|
};
|
||||||
|
|
||||||
UserTests::UserTests() {}
|
UserTests::UserTests() {}
|
||||||
@ -105,6 +108,39 @@ UserTests::testDefaultGroups()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UserTests::testHostActions_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn< bool >( "set" );
|
||||||
|
QTest::addColumn< QString >( "string" );
|
||||||
|
QTest::addColumn< int >( "result" );
|
||||||
|
|
||||||
|
QTest::newRow( "unset " ) << false << QString() << int( HostNameAction::EtcHostname );
|
||||||
|
QTest::newRow( "empty " ) << true << QString() << int( HostNameAction::EtcHostname );
|
||||||
|
QTest::newRow( "bad " ) << true << QString( "derp" ) << int( HostNameAction::EtcHostname );
|
||||||
|
QTest::newRow( "none " ) << true << QString( "none" ) << int( HostNameAction::None );
|
||||||
|
QTest::newRow( "systemd" ) << true << QString( "Hostnamed" ) << int( HostNameAction::SystemdHostname );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UserTests::testHostActions()
|
||||||
|
{
|
||||||
|
QFETCH( bool, set );
|
||||||
|
QFETCH( QString, string );
|
||||||
|
QFETCH( int, result );
|
||||||
|
|
||||||
|
QVariantMap m;
|
||||||
|
if ( set )
|
||||||
|
{
|
||||||
|
m.insert( "setHostname", string );
|
||||||
|
}
|
||||||
|
QCOMPARE( getHostNameActions( m ), HostNameActions( result ) | HostNameAction::WriteEtcHosts ); // write bits default to true
|
||||||
|
m.insert( "writeHostsFile", false );
|
||||||
|
QCOMPARE( getHostNameActions( m ), HostNameActions( result ) );
|
||||||
|
m.insert( "writeHostsFile", true );
|
||||||
|
QCOMPARE( getHostNameActions( m ), HostNameActions( result ) | HostNameAction::WriteEtcHosts );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN( UserTests )
|
QTEST_GUILESS_MAIN( UserTests )
|
||||||
|
|
||||||
|
@ -138,4 +138,5 @@ setHostname: EtcFile
|
|||||||
|
|
||||||
# Should /etc/hosts be written with a hostname for this machine
|
# Should /etc/hosts be written with a hostname for this machine
|
||||||
# (also adds localhost and some ipv6 standard entries).
|
# (also adds localhost and some ipv6 standard entries).
|
||||||
|
# Defaults to *true*.
|
||||||
writeHostsFile: true
|
writeHostsFile: true
|
||||||
|
Loading…
Reference in New Issue
Block a user