[users] Expand test to demo other template-keys

This commit is contained in:
Adriaan de Groot 2022-04-11 15:03:48 +02:00
parent dad12a0e02
commit 3b02115f8e

View File

@ -297,6 +297,13 @@ UserTests::testHostSuggestions_data()
<< QStringLiteral( "chuck-pc" ); // Avoid ${product} because it's DMI-based << QStringLiteral( "chuck-pc" ); // Avoid ${product} because it's DMI-based
QTest::newRow( "full " ) << QStringLiteral( "${name}" ) << QStringLiteral( "chuckyeager" ); QTest::newRow( "full " ) << QStringLiteral( "${name}" ) << QStringLiteral( "chuckyeager" );
QTest::newRow( "login+ " ) << QStringLiteral( "${login}-${first}" ) << QStringLiteral( "bill-chuck" ); QTest::newRow( "login+ " ) << QStringLiteral( "${login}-${first}" ) << QStringLiteral( "bill-chuck" );
// This is a bit dodgy: assumes CPU architecture of the testing host
QTest::newRow( " cpu " ) << QStringLiteral( "${cpu}X" ) << QStringLiteral( "x8664X" ); // Assume we don't test on non-amd64
// These have X X in the template to indicate that they are bogus. Mostly we want
// to see what the template engine does for these.
QTest::newRow( "@prod " ) << QStringLiteral( "X${product}X" ) << QString();
QTest::newRow( "@prod2 " ) << QStringLiteral( "X${product2}X" ) << QString();
QTest::newRow( "@host " ) << QStringLiteral( "X${host}X" ) << QString();
} }
void void
@ -308,6 +315,11 @@ UserTests::testHostSuggestions()
QFETCH( QString, templateString ); QFETCH( QString, templateString );
QFETCH( QString, result ); QFETCH( QString, result );
if ( templateString.startsWith('X') && templateString.endsWith('X'))
{
QEXPECT_FAIL( "", "Test is too host-specific", Continue );
cWarning() << Logger::SubEntry << "Next test" << templateString << "->" << makeHostnameSuggestion( templateString, fullName, login );
}
QCOMPARE( makeHostnameSuggestion( templateString, fullName, login ), result ); QCOMPARE( makeHostnameSuggestion( templateString, fullName, login ), result );
} }