Commit 6f001435 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Reduce duplicate code

parent 40bd2b9a
......@@ -137,35 +137,21 @@ ExportMailJobInterfaceTest::ExportMailJobInterfaceTest(QObject *parent)
{
}
void ExportMailJobInterfaceTest::exportMailConfig_data()
void ExportMailJobInterfaceTest::exportMail_data()
{
QTest::addColumn<QByteArray>("configpath");
QTest::addColumn<Utils::StoredTypes>("options");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
QTest::newRow("mailonlyconfig") << pathConfig + QByteArray("mailonlyconfig/");
Utils::StoredTypes options = {Utils::StoredType::Config};
QTest::newRow("mailonlyconfig") << pathConfig + QByteArray("mailonlyconfig/") << options;
options = {Utils::StoredType::Config|Utils::StoredType::Resources};
QTest::newRow("mailconfigandconfig") << pathConfig + QByteArray("mailconfigandconfig/") << options;
}
void ExportMailJobInterfaceTest::exportMailConfig()
{
QFETCH(QByteArray, configpath);
qDebug() << " configpath" << configpath;
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
ExportMailJobInterfaceTestImpl *exportNote = new ExportMailJobInterfaceTestImpl(this, {Utils::StoredType::Config}, file->archiveStorage(), 1);
file->setAbstractImportExportJob(exportNote);
file->start();
delete exportNote;
}
void ExportMailJobInterfaceTest::exportMailConfigAndResource_data()
{
QTest::addColumn<QByteArray>("configpath");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/export/");
QTest::newRow("mailconfigandconfig") << pathConfig + QByteArray("mailconfigandconfig/");
}
void ExportMailJobInterfaceTest::exportMailConfigAndResource()
void ExportMailJobInterfaceTest::exportMail()
{
QFETCH(QByteArray, configpath);
QFETCH(Utils::StoredTypes, options);
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
QVector<Utils::AkonadiInstanceInfo> lstInfo;
......@@ -181,7 +167,7 @@ void ExportMailJobInterfaceTest::exportMailConfigAndResource()
info.identifier = QStringLiteral("akonadi_kolab_resource_2");
lstInfo << info;
ExportMailJobInterfaceTestImpl *exportNote = new ExportMailJobInterfaceTestImpl(this, {Utils::StoredType::Config|Utils::StoredType::Resources}, file->archiveStorage(), 1);
ExportMailJobInterfaceTestImpl *exportNote = new ExportMailJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
exportNote->setListOfResource(lstInfo);
exportNote->setPathConfig(QLatin1String(configpath));
file->setAbstractImportExportJob(exportNote);
......
......@@ -60,10 +60,8 @@ public:
explicit ExportMailJobInterfaceTest(QObject *parent = nullptr);
~ExportMailJobInterfaceTest() = default;
private Q_SLOTS:
void exportMailConfig();
void exportMailConfig_data();
void exportMailConfigAndResource_data();
void exportMailConfigAndResource();
void exportMail();
void exportMail_data();
};
#endif // EXPORTMAILJOBINTERFACETEST_H
......@@ -21,10 +21,10 @@
#include "archivestorage.h"
#include "resourceconvertertest.h"
#include "testimportfile.h"
#include "utils.h"
#include <QSignalSpy>
#include <QTest>
QTEST_MAIN(ImportMailJobInterfaceTest)
ImportMailJobInterfaceTestImpl::ImportMailJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
: ImportMailJobInterface(parent, typeSelected, archiveStorage, numberOfStep)
{
......@@ -86,19 +86,22 @@ void ImportMailJobInterfaceTest::importMailConfig_data()
{
QTest::addColumn<QString>("zipFilePath");
QTest::addColumn<QString>("testPath");
QTest::addColumn<Utils::StoredTypes>("options");
const QByteArray pathConfig(QByteArray(PIMDATAEXPORTER_DIR) + "/import/");
QTest::newRow("mailonlyconfig") << QString::fromLatin1(pathConfig) << QStringLiteral("/mailonlyconfig/");
Utils::StoredTypes options = {Utils::StoredType::Config};
QTest::newRow("mailonlyconfig") << QString::fromLatin1(pathConfig) << QStringLiteral("/mailonlyconfig/") << options;
}
void ImportMailJobInterfaceTest::importMailConfig()
{
QFETCH(QString, zipFilePath);
QFETCH(QString, testPath);
QFETCH(Utils::StoredTypes, options);
TestImportFile *file = new TestImportFile(zipFilePath + testPath, this);
file->setPathConfig(zipFilePath + testPath);
file->setExtractPath(QDir::tempPath() + testPath);
file->setExcludePath(Utils::mailsPath()); // ???
ImportMailJobInterfaceTestImpl *impl = new ImportMailJobInterfaceTestImpl(this, {Utils::StoredType::Config}, file->archiveStorage(), 1);
ImportMailJobInterfaceTestImpl *impl = new ImportMailJobInterfaceTestImpl(this, options, file->archiveStorage(), 1);
file->setAbstractImportExportJob(impl);
file->setLoggingFilePath(impl->loggingFilePath());
file->start();
......
......@@ -120,4 +120,5 @@ PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString appTypeToI18n(AppsType type);
PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString storedTypeToI18n(StoredType type);
}
Q_DECLARE_TYPEINFO(Utils::AkonadiInstanceInfo, Q_MOVABLE_TYPE);
Q_DECLARE_METATYPE(Utils::StoredTypes)
#endif // UTILS_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment