From 8b5e49d9806b2c9fbfc5149a7e0107bceabfa40b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 13 Dec 2021 15:04:23 +0100 Subject: [PATCH] [preservefiles] Add (stub) tests --- src/modules/preservefiles/CMakeLists.txt | 9 ++- src/modules/preservefiles/Tests.cpp | 70 ++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/modules/preservefiles/Tests.cpp diff --git a/src/modules/preservefiles/CMakeLists.txt b/src/modules/preservefiles/CMakeLists.txt index e5cbe819c..5df637321 100644 --- a/src/modules/preservefiles/CMakeLists.txt +++ b/src/modules/preservefiles/CMakeLists.txt @@ -3,8 +3,6 @@ # SPDX-FileCopyrightText: 2020 Adriaan de Groot # SPDX-License-Identifier: BSD-2-Clause # -include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) - calamares_add_plugin( preservefiles TYPE job EXPORT_MACRO PLUGINDLLEXPORT_PRO @@ -15,3 +13,10 @@ calamares_add_plugin( preservefiles SHARED_LIB EMERGENCY ) + +calamares_add_test( + preservefilestest + SOURCES + Item.cpp + Tests.cpp +) diff --git a/src/modules/preservefiles/Tests.cpp b/src/modules/preservefiles/Tests.cpp new file mode 100644 index 000000000..3bf4aa833 --- /dev/null +++ b/src/modules/preservefiles/Tests.cpp @@ -0,0 +1,70 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2021 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#include "Item.h" + +#include "Settings.h" +#include "utils/CalamaresUtilsSystem.h" +#include "utils/Logger.h" +#include "utils/Yaml.h" + +#include + +class PreserveFilesTests : public QObject +{ + Q_OBJECT +public: + PreserveFilesTests(); + ~PreserveFilesTests() override {} + +private Q_SLOTS: + void initTestCase(); + + /* + void testOneUrl(); + void testUrls_data(); + void testUrls(); + + void testBadConfigDoesNotResetUrls(); + */ + void testTrue(); +}; + +PreserveFilesTests::PreserveFilesTests() {} + +void +PreserveFilesTests::initTestCase() +{ + Logger::setupLogLevel( Logger::LOGDEBUG ); + cDebug() << "PreserveFiles test started."; + + // Ensure we have a system object, expect it to be a "bogus" one + CalamaresUtils::System* system = CalamaresUtils::System::instance(); + QVERIFY( system ); + cDebug() << Logger::SubEntry << "System @" << Logger::Pointer( system ); + + const auto* settings = Calamares::Settings::instance(); + if ( !settings ) + { + (void)new Calamares::Settings( true ); + } +} + +void +PreserveFilesTests::testTrue() +{ + QVERIFY( true ); +} + + +QTEST_GUILESS_MAIN( PreserveFilesTests ) + +#include "utils/moc-warnings.h" + +#include "Tests.moc"