Files
Igor Malinovskiy 8bdc718511 0.9.8
- Fix locking of server item & allow to disconnect from server
- Improve server & console tabs
- Remove easyloging
- Allow to duplicate connection from inline menu
- Update translations
- Update welcome screen
- Fix "Reload" button
- Fix Live update

Fix #4182
Fix #4232
Fix #4242
Fix #3995
Fix #3634
Fix #4256
2018-10-09 17:45:03 +03:00

56 lines
1.7 KiB
C++

#include "test_connectionsmanager.h"
#include <QDir>
#include <QFile>
#include <QModelIndex>
#include <QtTest/QtTest>
#include "app/events.h"
#include "models/connectionsmanager.h"
TestConnectionsManager::TestConnectionsManager() {}
void TestConnectionsManager::loadConnectionsConfigFromFile() {
// given
// xml fixture
QString configTestFile = "./unit_tests/testcases/app/connections.json";
auto events = QSharedPointer<Events>(new Events());
// when loads connections
ConnectionsManager testManager(configTestFile, events);
// then
QCOMPARE(testManager.size(), 1);
}
void TestConnectionsManager::saveConnectionsConfigToFile_data() {
QTest::addColumn<QString>("connectionName");
QTest::newRow("simple") << "test";
QTest::newRow("unicode") << "❤❤❤༆";
}
void TestConnectionsManager::saveConnectionsConfigToFile() {
// given
QFETCH(QString, connectionName);
QString configTestFile = QString("%1/test_rdm.json").arg(QDir::tempPath());
QFile::remove(configTestFile);
RedisClient::ConnectionConfig connectionConfig =
getDummyConfig(connectionName);
auto events = QSharedPointer<Events>(new Events());
ConnectionsManager testManager(configTestFile, events);
// when
// add new connection and save
testManager.addNewConnection(connectionConfig, true);
// load everything from scratch
ConnectionsManager testManagerNew(configTestFile, events);
QModelIndex testIndex = testManagerNew.index(0, 0, QModelIndex());
QString actualConnectionName =
testManagerNew.data(testIndex, ConnectionsTree::Model::itemName)
.toString();
// then
qDebug() << "Actual name: " << actualConnectionName;
QCOMPARE(QFile::exists(configTestFile), true);
QCOMPARE(actualConnectionName, connectionName);
}