From a40ea0948d9af25fbfe80c53b0e23747e84ba9e8 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Mon, 28 Sep 2015 18:03:02 +0200 Subject: [PATCH] MySql: add failing connection test This test ensure that a connection made to either an invalid host or an unreachable host fails properly. Task-number: QTBUG-47452 Change-Id: If31d23d815e496fc21ef2e1e19c34c2723bd3504 Reviewed-by: Oswald Buddenhagen Reviewed-by: Andy Shaw Reviewed-by: Thiago Macieira --- tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 1993f23672..975a17f93d 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -146,6 +146,7 @@ private slots: void mysql_multiselect(); // For task 144331 void mysql_savepointtest_data() { generic_data("QMYSQL"); } void mysql_savepointtest(); + void mysql_connectWithInvalidAddress(); void accessOdbc_strings_data() { generic_data(); } void accessOdbc_strings(); @@ -2192,6 +2193,14 @@ void tst_QSqlDatabase::mysql_savepointtest() QVERIFY_SQL(q, exec("savepoint foo")); } +void tst_QSqlDatabase::mysql_connectWithInvalidAddress() +{ + // Ensure that giving invalid connection parameters fails correctly + QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); + db.setHostName("invalid.local"); + QCOMPARE(db.open(), false); +} + void tst_QSqlDatabase::oci_tables() { QSKIP("Requires specific permissions to create a system table");