File indexing completed on 2024-12-22 05:05:23

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "exportcalendarsjobinterfacetest.h"
0008 #include "archivestorage.h"
0009 #include "exportcalendarsjobinterfacetestimpl.h"
0010 #include "testexportfile.h"
0011 #include <QTest>
0012 #include <memory>
0013 QTEST_MAIN(ExportCalendarsJobInterfaceTest)
0014 
0015 ExportCalendarsJobInterfaceTest::ExportCalendarsJobInterfaceTest(QObject *parent)
0016     : QObject(parent)
0017 {
0018 }
0019 
0020 void ExportCalendarsJobInterfaceTest::exportCalendar_data()
0021 {
0022     QTest::addColumn<QByteArray>("configpath");
0023     QTest::addColumn<Utils::StoredTypes>("options");
0024     Utils::StoredTypes options = {Utils::StoredType::Config};
0025     const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
0026     QTest::newRow("calendaronlyconfig") << pathConfig + QByteArray("calendaronlyconfig/") << options;
0027     options = {Utils::StoredType::Config | Utils::StoredType::Resources};
0028     QTest::newRow("calendarconfigandresources") << pathConfig + QByteArray("calendarconfigandresources/") << options;
0029     options = {Utils::StoredType::Config | Utils::StoredType::Resources};
0030     QTest::newRow("calendarconfigandresourceskalendar") << pathConfig + QByteArray("calendarconfigandresourceskalendar/") << options;
0031 }
0032 
0033 void ExportCalendarsJobInterfaceTest::exportCalendar()
0034 {
0035     QFETCH(QByteArray, configpath);
0036     QFETCH(Utils::StoredTypes, options);
0037     std::unique_ptr<TestExportFile> file{new TestExportFile(this)};
0038     file->setPathConfig(configpath);
0039     QList<Utils::AkonadiInstanceInfo> lstInfo;
0040     Utils::AkonadiInstanceInfo info;
0041     info.identifier = QStringLiteral("akonadi_icaldir_resource_1");
0042     lstInfo << info;
0043     info.identifier = QStringLiteral("akonadi_ical_resource_2");
0044     lstInfo << info;
0045     info.identifier = QStringLiteral("akonadi_davgroupware_resource_0");
0046     lstInfo << info;
0047     // Add extra resource.
0048     info.identifier = QStringLiteral("akonadi_contacts_resource_1");
0049     lstInfo << info;
0050     info.identifier = QStringLiteral("akonadi_kontact_resource_2");
0051     lstInfo << info;
0052 
0053     auto exportNote = new ExportCalendarsJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
0054     exportNote->setListOfResource(lstInfo);
0055     exportNote->setPathConfig(QLatin1StringView(configpath));
0056     file->setAbstractImportExportJob(exportNote);
0057     file->start();
0058     delete exportNote;
0059 }
0060 
0061 #include "moc_exportcalendarsjobinterfacetest.cpp"