mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[2821] Move library_end to holder
and use the holder in the unit tests as well
This commit is contained in:
@@ -59,6 +59,8 @@ public:
|
|||||||
if (mysql_ != NULL) {
|
if (mysql_ != NULL) {
|
||||||
mysql_close(mysql_);
|
mysql_close(mysql_);
|
||||||
}
|
}
|
||||||
|
// The library itself shouldn't be needed anymore
|
||||||
|
mysql_library_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Conversion Operator
|
/// @brief Conversion Operator
|
||||||
|
@@ -118,21 +118,16 @@ validConnectionString() {
|
|||||||
// There is no error checking in this code: if something fails, one of the
|
// There is no error checking in this code: if something fails, one of the
|
||||||
// tests will (should) fall over.
|
// tests will (should) fall over.
|
||||||
void destroySchema() {
|
void destroySchema() {
|
||||||
// Initialise
|
MySqlHolder mysql;
|
||||||
MYSQL handle;
|
|
||||||
(void) mysql_init(&handle);
|
|
||||||
|
|
||||||
// Open database
|
// Open database
|
||||||
(void) mysql_real_connect(&handle, "localhost", "keatest",
|
(void) mysql_real_connect(mysql, "localhost", "keatest",
|
||||||
"keatest", "keatest", 0, NULL, 0);
|
"keatest", "keatest", 0, NULL, 0);
|
||||||
|
|
||||||
// Get rid of everything in it.
|
// Get rid of everything in it.
|
||||||
for (int i = 0; destroy_statement[i] != NULL; ++i) {
|
for (int i = 0; destroy_statement[i] != NULL; ++i) {
|
||||||
(void) mysql_query(&handle, destroy_statement[i]);
|
(void) mysql_query(mysql, destroy_statement[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ... and close
|
|
||||||
(void) mysql_close(&handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @brief Create the Schema
|
// @brief Create the Schema
|
||||||
@@ -142,21 +137,16 @@ void destroySchema() {
|
|||||||
// There is no error checking in this code: if it fails, one of the tests
|
// There is no error checking in this code: if it fails, one of the tests
|
||||||
// will fall over.
|
// will fall over.
|
||||||
void createSchema() {
|
void createSchema() {
|
||||||
// Initialise
|
MySqlHolder mysql;
|
||||||
MYSQL handle;
|
|
||||||
(void) mysql_init(&handle);
|
|
||||||
|
|
||||||
// Open database
|
// Open database
|
||||||
(void) mysql_real_connect(&handle, "localhost", "keatest",
|
(void) mysql_real_connect(mysql, "localhost", "keatest",
|
||||||
"keatest", "keatest", 0, NULL, 0);
|
"keatest", "keatest", 0, NULL, 0);
|
||||||
|
|
||||||
// Execute creation statements.
|
// Execute creation statements.
|
||||||
for (int i = 0; create_statement[i] != NULL; ++i) {
|
for (int i = 0; create_statement[i] != NULL; ++i) {
|
||||||
(void) mysql_query(&handle, create_statement[i]);
|
(void) mysql_query(mysql, create_statement[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ... and close
|
|
||||||
(void) mysql_close(&handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Test fixture class for testing MySQL Lease Manager
|
/// @brief Test fixture class for testing MySQL Lease Manager
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#ifdef HAVE_MYSQL
|
|
||||||
#include <mysql/mysql.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char* argv[]) {
|
main(int argc, char* argv[]) {
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
@@ -28,9 +24,5 @@ main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
int result = RUN_ALL_TESTS();
|
int result = RUN_ALL_TESTS();
|
||||||
|
|
||||||
#ifdef HAVE_MYSQL
|
|
||||||
mysql_library_end();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user