Added isConnected() method to client to work around disconnect issue with test suite.
This commit is contained in:
parent
32f01b33cb
commit
2c4b533124
|
|
@ -46,6 +46,12 @@ namespace QRedis
|
|||
*/
|
||||
void disconnectFromHost();
|
||||
|
||||
/**
|
||||
* @brief Indicates whether the client is connected to a Redis server
|
||||
* @return true if the client is connected
|
||||
*/
|
||||
bool isConnected() const;
|
||||
|
||||
/**
|
||||
* @brief Sends the specified command to the Redis server
|
||||
* @param command the command to execute
|
||||
|
|
|
|||
|
|
@ -88,6 +88,11 @@ void Client::disconnectFromHost()
|
|||
d->socket.disconnectFromHost();
|
||||
}
|
||||
|
||||
bool Client::isConnected() const
|
||||
{
|
||||
return d->socket.state() == QAbstractSocket::ConnectedState;
|
||||
}
|
||||
|
||||
Request * Client::sendCommand(const QString & command)
|
||||
{
|
||||
d->socket.write(QString("%1\r\n").arg(command).toUtf8());
|
||||
|
|
|
|||
|
|
@ -11,5 +11,7 @@ void TestClient::initTestCase()
|
|||
void TestClient::cleanupTestCase()
|
||||
{
|
||||
client.disconnectFromHost();
|
||||
QVERIFY(client.waitForDisconnected());
|
||||
|
||||
if(client.isConnected())
|
||||
QVERIFY(client.waitForDisconnected());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue