summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 11:46:45 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 11:46:45 +0200
commite3da13d1fe9ad623e05aec1977c813e7da37cedd (patch)
tree79266f2fba9e50c6e6d9d38d3baeff2d6a8e1e0e
parentab7c366b27a07cc31730dc7fb696cdc2519bb8d3 (diff)
downloadsink-e3da13d1fe9ad623e05aec1977c813e7da37cedd.tar.gz
sink-e3da13d1fe9ad623e05aec1977c813e7da37cedd.zip
Fail quickly if the backend is not available
-rw-r--r--examples/imapresource/tests/imapmailsynctest.cpp8
-rw-r--r--examples/imapresource/tests/imapmailtest.cpp8
-rw-r--r--examples/imapresource/tests/imapserverproxytest.cpp4
-rw-r--r--tests/mailsynctest.cpp1
-rw-r--r--tests/mailsynctest.h1
-rw-r--r--tests/mailtest.cpp1
-rw-r--r--tests/mailtest.h1
7 files changed, 24 insertions, 0 deletions
diff --git a/examples/imapresource/tests/imapmailsynctest.cpp b/examples/imapresource/tests/imapmailsynctest.cpp
index 968cde5..fcc659d 100644
--- a/examples/imapresource/tests/imapmailsynctest.cpp
+++ b/examples/imapresource/tests/imapmailsynctest.cpp
@@ -17,6 +17,7 @@
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */ 18 */
19#include <QtTest> 19#include <QtTest>
20#include <QTcpSocket>
20 21
21#include <tests/mailsynctest.h> 22#include <tests/mailsynctest.h>
22#include "../imapresource.h" 23#include "../imapresource.h"
@@ -38,6 +39,13 @@ class ImapMailSyncTest : public Sink::MailSyncTest
38 Q_OBJECT 39 Q_OBJECT
39 40
40protected: 41protected:
42 bool isBackendAvailable() Q_DECL_OVERRIDE
43 {
44 QTcpSocket socket;
45 socket.connectToHost("localhost", 993);
46 return socket.waitForConnected(200);
47 }
48
41 void resetTestEnvironment() Q_DECL_OVERRIDE 49 void resetTestEnvironment() Q_DECL_OVERRIDE
42 { 50 {
43 system("resetmailbox.sh"); 51 system("resetmailbox.sh");
diff --git a/examples/imapresource/tests/imapmailtest.cpp b/examples/imapresource/tests/imapmailtest.cpp
index c94a731..e6f41f4 100644
--- a/examples/imapresource/tests/imapmailtest.cpp
+++ b/examples/imapresource/tests/imapmailtest.cpp
@@ -1,4 +1,5 @@
1#include <QtTest> 1#include <QtTest>
2#include <QTcpSocket>
2 3
3#include <tests/mailtest.h> 4#include <tests/mailtest.h>
4 5
@@ -18,6 +19,13 @@ class ImapMailTest : public Sink::MailTest
18 Q_OBJECT 19 Q_OBJECT
19 20
20protected: 21protected:
22 bool isBackendAvailable() Q_DECL_OVERRIDE
23 {
24 QTcpSocket socket;
25 socket.connectToHost("localhost", 993);
26 return socket.waitForConnected(200);
27 }
28
21 void resetTestEnvironment() Q_DECL_OVERRIDE 29 void resetTestEnvironment() Q_DECL_OVERRIDE
22 { 30 {
23 system("resetmailbox.sh"); 31 system("resetmailbox.sh");
diff --git a/examples/imapresource/tests/imapserverproxytest.cpp b/examples/imapresource/tests/imapserverproxytest.cpp
index e32298c..6819685 100644
--- a/examples/imapresource/tests/imapserverproxytest.cpp
+++ b/examples/imapresource/tests/imapserverproxytest.cpp
@@ -2,6 +2,7 @@
2 2
3#include <QString> 3#include <QString>
4#include <KMime/Message> 4#include <KMime/Message>
5#include <QTcpSocket>
5 6
6#include "../imapserverproxy.h" 7#include "../imapserverproxy.h"
7 8
@@ -22,6 +23,9 @@ class ImapServerProxyTest : public QObject
22private slots: 23private slots:
23 void initTestCase() 24 void initTestCase()
24 { 25 {
26 QTcpSocket socket;
27 socket.connectToHost("localhost", 993);
28 QVERIFY(socket.waitForConnected(200));
25 Sink::Log::setDebugOutputLevel(Sink::Log::Trace); 29 Sink::Log::setDebugOutputLevel(Sink::Log::Trace);
26 system("resetmailbox.sh"); 30 system("resetmailbox.sh");
27 } 31 }
diff --git a/tests/mailsynctest.cpp b/tests/mailsynctest.cpp
index e70e34e..faaf003 100644
--- a/tests/mailsynctest.cpp
+++ b/tests/mailsynctest.cpp
@@ -34,6 +34,7 @@ using namespace Sink::ApplicationDomain;
34void MailSyncTest::initTestCase() 34void MailSyncTest::initTestCase()
35{ 35{
36 Test::initTest(); 36 Test::initTest();
37 QVERIFY(isBackendAvailable());
37 Log::setDebugOutputLevel(Sink::Log::Trace); 38 Log::setDebugOutputLevel(Sink::Log::Trace);
38 resetTestEnvironment(); 39 resetTestEnvironment();
39 auto resource = createResource(); 40 auto resource = createResource();
diff --git a/tests/mailsynctest.h b/tests/mailsynctest.h
index a21335b..31d3f03 100644
--- a/tests/mailsynctest.h
+++ b/tests/mailsynctest.h
@@ -41,6 +41,7 @@ protected:
41 QByteArray mResourceInstanceIdentifier; 41 QByteArray mResourceInstanceIdentifier;
42 QByteArrayList mCapabilities; 42 QByteArrayList mCapabilities;
43 43
44 virtual bool isBackendAvailable() { return true; }
44 virtual void resetTestEnvironment() = 0; 45 virtual void resetTestEnvironment() = 0;
45 virtual Sink::ApplicationDomain::SinkResource createResource() = 0; 46 virtual Sink::ApplicationDomain::SinkResource createResource() = 0;
46 virtual Sink::ApplicationDomain::SinkResource createFaultyResource() = 0; 47 virtual Sink::ApplicationDomain::SinkResource createFaultyResource() = 0;
diff --git a/tests/mailtest.cpp b/tests/mailtest.cpp
index b9d496d..8031cf1 100644
--- a/tests/mailtest.cpp
+++ b/tests/mailtest.cpp
@@ -34,6 +34,7 @@ using namespace Sink::ApplicationDomain;
34void MailTest::initTestCase() 34void MailTest::initTestCase()
35{ 35{
36 Test::initTest(); 36 Test::initTest();
37 QVERIFY(isBackendAvailable());
37 Log::setDebugOutputLevel(Sink::Log::Trace); 38 Log::setDebugOutputLevel(Sink::Log::Trace);
38 resetTestEnvironment(); 39 resetTestEnvironment();
39 auto resource = createResource(); 40 auto resource = createResource();
diff --git a/tests/mailtest.h b/tests/mailtest.h
index 2144bf1..cba623d 100644
--- a/tests/mailtest.h
+++ b/tests/mailtest.h
@@ -34,6 +34,7 @@ protected:
34 QByteArray mResourceInstanceIdentifier; 34 QByteArray mResourceInstanceIdentifier;
35 QByteArrayList mCapabilities; 35 QByteArrayList mCapabilities;
36 36
37 virtual bool isBackendAvailable() { return true; }
37 virtual void resetTestEnvironment() = 0; 38 virtual void resetTestEnvironment() = 0;
38 virtual Sink::ApplicationDomain::SinkResource createResource() = 0; 39 virtual Sink::ApplicationDomain::SinkResource createResource() = 0;
39 40