Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uglide committed Jul 31, 2016
1 parent 7d733e0 commit 8e0b6ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/unit_tests/basetestcase.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BaseTestCase : public QObject

QSharedPointer<DummyConnection> getFakeConnection(const QList<QVariant>& expectedScanResponses = QList<QVariant>(),
const QStringList& expectedResponses = QStringList(),
double version=2.6,
double version=2.8,
bool raise_error=false);

void wait(int ms);
Expand Down
15 changes: 13 additions & 2 deletions tests/unit_tests/mocks/dummyconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class DummyConnection : public RedisClient::Connection
: RedisClient::Connection(RedisClient::ConnectionConfig()),
runCommandCalled(0), retrieveCollectionCalled(0),
getServerVersionCalled(0), m_version(version),
m_raiseExceptionOnConnect(raise_error)
m_raiseExceptionOnConnect(raise_error),
returnErrorOnCmdRun(false)
{
}

Expand Down Expand Up @@ -55,6 +56,12 @@ class DummyConnection : public RedisClient::Connection
{
RedisClient::Response resp;

if (returnErrorOnCmdRun) {
auto callback = cmd.getCallBack();
callback(resp, QString("fake error"));
return;
}

if (fakeResponses.size()) {
resp = fakeResponses.first();
fakeResponses.removeFirst();
Expand All @@ -65,7 +72,8 @@ class DummyConnection : public RedisClient::Connection
auto callback = cmd.getCallBack();
callback(resp, QString());

runCommandCalled++;
runCommandCalled++;
executedCommands.push_back(cmd);
}

uint runCommandCalled;
Expand All @@ -88,6 +96,9 @@ class DummyConnection : public RedisClient::Connection
}
}

QList<RedisClient::Command> executedCommands;
bool returnErrorOnCmdRun;

private:
double m_version;
bool m_raiseExceptionOnConnect;
Expand Down

0 comments on commit 8e0b6ec

Please sign in to comment.