From cb20ba6aba632b85302379511b0d5976def995fc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 7 Aug 2020 01:11:14 +0200 Subject: [PATCH] [libcalamares] More GS load/save testing - failures elsewhere boil down to QStringList is not supported, but a QVariantList of QVariants of QStrings is. --- src/libcalamares/Tests.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/libcalamares/Tests.cpp b/src/libcalamares/Tests.cpp index 744e56113..bf419d721 100644 --- a/src/libcalamares/Tests.cpp +++ b/src/libcalamares/Tests.cpp @@ -21,6 +21,8 @@ #include "GlobalStorage.h" +#include "utils/Logger.h" + #include #include #include @@ -35,6 +37,7 @@ public: private Q_SLOTS: void testGSModify(); void testGSLoadSave(); + void testGSLoadSave2(); }; void @@ -107,6 +110,35 @@ TestLibCalamares::testGSLoadSave() QCOMPARE( gs4.value( "derp" ).toInt(), 17 ); // This one was overwritten } +void +TestLibCalamares::testGSLoadSave2() +{ + Logger::setupLogLevel( Logger::LOGDEBUG ); + + const QString filename( "../src/libcalamares/testdata/yaml-list.conf" ); + if ( !QFile::exists( filename ) ) + { + return; + } + + Calamares::GlobalStorage gs1; + const QString key( "dwarfs" ); + + QVERIFY( gs1.loadYaml( filename ) ); + QCOMPARE( gs1.count(), 3 ); // From examining the file + QVERIFY( gs1.contains( key ) ); + cDebug() << gs1.value( key ).type() << gs1.value( key ); + QCOMPARE( gs1.value( key ).type(), QVariant::List ); + + const QString yamlfilename( "gs.test.yaml" ); + QVERIFY( gs1.saveYaml( yamlfilename ) ); + + Calamares::GlobalStorage gs2; + QVERIFY( gs2.loadYaml( yamlfilename ) ); + QVERIFY( gs2.contains( key ) ); + QCOMPARE( gs2.value( key ).type(), QVariant::List ); +} + QTEST_GUILESS_MAIN( TestLibCalamares )