summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJo Asplin <jo.asplin@nokia.com>2012-06-04 13:41:34 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-04 14:22:45 +0200
commit58b830b082ab47078510c72576281dbc0da964f6 (patch)
tree6d833b177d1f1e172e874017bb240784ee6de508 /tests
parente78e1f5b06decad26af1826b192d34042ca45c4d (diff)
Don't mess up JSONDB_SOCKET environment variable
TestQJsonDbRequest::dontAllowDefaultAndRemovablePartition() launches a secondary test daemon that updates the global JSONDB_SOCKET environment variable as a side effect. It therefore needs to restore it back to the primary value after each call. Also eliminate runtime warnings due to the path not being explicitly set in the partition definition. Change-Id: I2a201d4f4fff419f0f6d04582c4c4210ea0094f0 Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qjsondbrequest/testqjsondbrequest.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/auto/qjsondbrequest/testqjsondbrequest.cpp b/tests/auto/qjsondbrequest/testqjsondbrequest.cpp
index 94fb4b08..69feab89 100644
--- a/tests/auto/qjsondbrequest/testqjsondbrequest.cpp
+++ b/tests/auto/qjsondbrequest/testqjsondbrequest.cpp
@@ -118,6 +118,8 @@ private slots:
private:
bool writeTestObject(QObject* parent, const QString &type, int value, const QString &partition = QString());
+
+ QByteArray primaryJsonDbSocket;
};
void TestQJsonDbRequest::initTestCase()
@@ -141,13 +143,21 @@ void TestQJsonDbRequest::cleanupTestCase()
void TestQJsonDbRequest::init()
{
- clearHelperData();
- connectToServer();
+ if (qstrcmp(QTest::currentTestFunction(), "dontAllowDefaultAndRemovablePartition") == 0) {
+ primaryJsonDbSocket = qgetenv("JSONDB_SOCKET"); // save original
+ } else {
+ clearHelperData();
+ connectToServer();
+ }
}
void TestQJsonDbRequest::cleanup()
{
- disconnectFromServer();
+ if (qstrcmp(QTest::currentTestFunction(), "dontAllowDefaultAndRemovablePartition") == 0) {
+ qputenv("JSONDB_SOCKET", primaryJsonDbSocket); // restore original
+ } else {
+ disconnectFromServer();
+ }
}
void TestQJsonDbRequest::modifyPartitions()
@@ -1374,6 +1384,7 @@ void TestQJsonDbRequest::dontAllowDefaultAndRemovablePartition()
// Partition 1:
QJsonObject jobj1;
jobj1.insert(QLatin1String("name"), QLatin1String("dummy1"));
+ jobj1.insert(QLatin1String("path"), QLatin1String("."));
if (!default1.isEmpty())
jobj1.insert(QLatin1String("default"), IS_TRUE(default1));
if (!removable1.isEmpty())
@@ -1382,6 +1393,7 @@ void TestQJsonDbRequest::dontAllowDefaultAndRemovablePartition()
// Partition 2:
QJsonObject jobj2;
jobj2.insert(QLatin1String("name"), QLatin1String("dummy2"));
+ jobj2.insert(QLatin1String("path"), QLatin1String("."));
if (!default2.isEmpty())
jobj2.insert(QLatin1String("default"), IS_TRUE(default2));
if (!removable2.isEmpty())