[partition] Test for basic legacy configuration

This commit is contained in:
Adriaan de Groot 2023-11-12 22:28:27 +01:00
parent 13acdace42
commit f07e31de29
3 changed files with 46 additions and 5 deletions

View File

@ -0,0 +1,2 @@
---
efiSystemPartitionSize: 100MiB

View File

@ -0,0 +1,2 @@
---
efiSystemPartitionSize: 100MB

View File

@ -9,12 +9,13 @@
#include "Config.h"
#include "core/PartUtils.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "core/PartUtils.h"
#include "utils/Yaml.h"
#include <QObject>
#include <QtTest/QtTest>
@ -31,6 +32,7 @@ public:
private Q_SLOTS:
void initTestCase();
void testEmptyConfig();
void testLegacySize();
};
ConfigTests::ConfigTests() = default;
@ -38,7 +40,7 @@ ConfigTests::ConfigTests() = default;
void
ConfigTests::initTestCase()
{
Logger::setupLogLevel( Logger::LOGDEBUG );
Logger::setupLogLevel( Logger::LOGVERBOSE );
// Ensure we have a system object, expect it to be a "bogus" one
Calamares::System* system = Calamares::System::instance();
@ -60,8 +62,6 @@ ConfigTests::initTestCase()
void
ConfigTests::testEmptyConfig()
{
Logger::setupLogLevel( Logger::LOGVERBOSE );
Config c( nullptr );
c.setConfigurationMap( {} );
@ -79,6 +79,43 @@ ConfigTests::testEmptyConfig()
QCOMPARE( gs->value( "efiSystemPartition" ).toString(), "/boot/efi" ); // Default
}
void
ConfigTests::testLegacySize()
{
Config c( nullptr );
const auto* gs = Calamares::JobQueue::instanceGlobalStorage();
QVERIFY( gs );
// Config with just one legacy key
{
const auto file = QStringLiteral( BUILD_AS_TEST "/1a-legacy.conf" );
bool ok = false;
c.setConfigurationMap( Calamares::YAML::load( file, &ok ) );
cDebug() << "Tried to load" << file << "success?" << ok;
QVERIFY( ok );
QVERIFY( gs->value( PartUtils::efiFilesystemRecommendedSizeGSKey() ).isValid() ); // Something was filled in
QCOMPARE( PartUtils::efiFilesystemRecommendedSize(), 100_MiB ); // From config
QCOMPARE( PartUtils::efiFilesystemMinimumSize(), 100_MiB ); // Taken from config
}
// Different legacy key value
{
bool ok = false;
c.setConfigurationMap( Calamares::YAML::load( QStringLiteral( BUILD_AS_TEST "/1b-legacy.conf" ), &ok ) );
QVERIFY( ok );
QCOMPARE( PartUtils::efiFilesystemRecommendedSize(), 100000000 ); // From config, MB
QCOMPARE( PartUtils::efiFilesystemMinimumSize(), 100000000 ); // Taken from config
}
}
QTEST_GUILESS_MAIN( ConfigTests )
#include "utils/moc-warnings.h"