1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
/*
SPDX-FileCopyrightText: 2020 Daniel Vrátil <dvratil@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <QTest>
#include "kimap/closejob.h"
#include "kimap/session.h"
#include "kimaptest/fakeserver.h"
#include <QTest>
class CloseJobTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testClose_data()
{
QTest::addColumn<QList<QByteArray>>("scenario");
QTest::addColumn<quint64>("highestModSeq");
QList<QByteArray> scenario;
scenario << FakeServer::preauth() << "C: A000001 CLOSE"
<< "S: A000001 OK Closed";
QTest::newRow("good") << scenario << 0ULL;
scenario.clear();
scenario << FakeServer::preauth() << "C: A000001 CLOSE"
<< "S: A000001 BAD No mailbox selected";
QTest::newRow("bad") << scenario << 0ULL;
scenario.clear();
scenario << FakeServer::preauth() << "C: A000001 CLOSE"
<< "S: A000001 OK [HIGHESTMODSEQ 123456789] Closed.";
QTest::newRow("qresync") << scenario << 123456789ULL;
}
void testClose()
{
QFETCH(QList<QByteArray>, scenario);
QFETCH(quint64, highestModSeq);
FakeServer fakeServer;
fakeServer.setScenario(scenario);
fakeServer.startAndWait();
KIMAP::Session session(QStringLiteral("127.0.0.1"), 5989);
auto job = new KIMAP::CloseJob(&session);
bool result = job->exec();
QEXPECT_FAIL("bad", "Expected failure on BAD response", Continue);
QVERIFY(result);
if (result) {
QCOMPARE(job->newHighestModSeq(), highestModSeq);
}
fakeServer.quit();
}
};
QTEST_GUILESS_MAIN(CloseJobTest)
#include "closejobtest.moc"
|