[users] Simplify test, fewer magic numbers

This commit is contained in:
Adriaan de Groot 2022-04-11 14:55:05 +02:00
parent c28ba5ffb2
commit dad12a0e02

View File

@ -92,18 +92,19 @@ UsersTests::testEtcHostname()
QVERIFY( QFile::exists( m_dir.path() ) );
QVERIFY( !QFile::exists( m_dir.filePath( "etc" ) ) );
const QString testHostname = QStringLiteral( "tubophone.calamares.io" );
// Doesn't create intermediate directories
QVERIFY( !setFileHostname( QStringLiteral( "tubophone.calamares.io" ) ) );
QVERIFY( !setFileHostname( testHostname ) );
QVERIFY( CalamaresUtils::System::instance()->createTargetDirs( "/etc" ) );
QVERIFY( QFile::exists( m_dir.filePath( "etc" ) ) );
// Does write the file
QVERIFY( setFileHostname( QStringLiteral( "tubophone.calamares.io" ) ) );
QVERIFY( setFileHostname( testHostname ) );
QVERIFY( QFile::exists( m_dir.filePath( "etc/hostname" ) ) );
// 22 for the test string, above, and 1 for the newline
QCOMPARE( QFileInfo( m_dir.filePath( "etc/hostname" ) ).size(), 22 + 1 );
QCOMPARE( QFileInfo( m_dir.filePath( "etc/hostname" ) ).size(), testHostname.length() + 1 );
}
void