[libcalamares] Handle multiple invalid URLs at once

- expand tests with example where more than one URL is invalid
- fix the call to the wrong overload of QVector::erase()
This commit is contained in:
Adriaan de Groot 2021-08-26 14:32:57 +02:00
parent 653359d815
commit 0538881447
2 changed files with 11 additions and 1 deletions

View File

@ -222,7 +222,7 @@ Manager::setCheckHasInternetUrl( const QVector< QUrl >& urls )
d->m_hasInternetUrls.begin(), d->m_hasInternetUrls.end(), []( const QUrl& u ) { return !u.isValid(); } );
if ( it != d->m_hasInternetUrls.end() )
{
d->m_hasInternetUrls.erase( it );
d->m_hasInternetUrls.erase( it, d->m_hasInternetUrls.end() );
}
}

View File

@ -134,4 +134,14 @@ NetworkTests::testCheckMultiUrl()
QVERIFY( nam.checkHasInternet() );
QCOMPARE( nam.getCheckInternetUrls().count(), 2 );
}
{
QUrl u0( "http://nonexistent.example.com" );
QUrl u1;
QVERIFY( u0.isValid() );
QVERIFY( !u1.isValid() );
nam.setCheckHasInternetUrl( { u1, u1, u1, u1 } );
QCOMPARE( nam.getCheckInternetUrls().count(), 0 );
nam.setCheckHasInternetUrl( { u1, u1, u0, u1 } );
QCOMPARE( nam.getCheckInternetUrls().count(), 1 );
}
}