[welcome] Add a handful of tests for different URL configs

This commit is contained in:
Adriaan de Groot 2021-08-26 16:58:46 +02:00
parent ad76a2cbe8
commit f376b42c31
8 changed files with 69 additions and 0 deletions

View File

@ -29,6 +29,8 @@ private Q_SLOTS:
void initTestCase();
void testOneUrl();
void testUrls_data();
void testUrls();
};
WelcomeTests::WelcomeTests() {}
@ -71,6 +73,41 @@ WelcomeTests::testOneUrl()
QCOMPARE( CalamaresUtils::Network::Manager::instance().getCheckInternetUrls().count(), 1 );
}
void
WelcomeTests::testUrls_data()
{
QTest::addColumn< QString >( "filename" );
QTest::addColumn< int >( "result" );
QTest::newRow( "one " ) << QString( "1a-checkinternet.conf" ) << 1;
QTest::newRow( "none " ) << QString( "1b-checkinternet.conf" ) << 0;
QTest::newRow( "blank" ) << QString( "1c-checkinternet.conf" ) << 0;
QTest::newRow( "bogus" ) << QString( "1d-checkinternet.conf" ) << 0;
QTest::newRow( "[] " ) << QString( "1e-checkinternet.conf" ) << 0;
QTest::newRow( "-3 " ) << QString( "1f-checkinternet.conf" ) << 3;
QTest::newRow( "[3] " ) << QString( "1g-checkinternet.conf" ) << 3;
QTest::newRow( "some " ) << QString( "1h-checkinternet.conf" ) << 3;
}
void
WelcomeTests::testUrls()
{
QFETCH( QString, filename );
QFETCH( int, result );
Config c;
// BUILD_AS_TEST is the source-directory path
QFile fi( QString( "%1/tests/%2" ).arg( BUILD_AS_TEST, filename ) );
QVERIFY( fi.exists() );
bool ok = false;
const auto map = CalamaresUtils::loadYaml( fi, &ok );
QVERIFY( ok );
c.setConfigurationMap( map );
QCOMPARE( CalamaresUtils::Network::Manager::instance().getCheckInternetUrls().count(), result );
}
QTEST_GUILESS_MAIN( WelcomeTests )

View File

@ -0,0 +1,3 @@
# Nothing at all
---
bogus: 1

View File

@ -0,0 +1,4 @@
# Set to blank
---
requirements:
internetCheckUrl: ""

View File

@ -0,0 +1,4 @@
# Set to something broken
---
requirements:
internetCheckUrl: false

View File

@ -0,0 +1,4 @@
# Empty list
---
requirements:
internetCheckUrl: []

View File

@ -0,0 +1,6 @@
---
requirements:
internetCheckUrl:
- http://example.com
- http://bogus.example.com
- http://nonexistent.example.com

View File

@ -0,0 +1,3 @@
---
requirements:
internetCheckUrl: [ http://example.com, http://bogus.example.com, http://nonexistent.example.com ]

View File

@ -0,0 +1,8 @@
# "0" is a valid URL (?) but "" is not
---
requirements:
internetCheckUrl:
- http://example.com
- 0
- ""
- http://nonexistent.example.com