[libgda] Improved tests regarding providers handling of dates
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Improved tests regarding providers handling of dates
- Date: Sun, 29 Sep 2013 16:41:17 +0000 (UTC)
commit d3b4f35bdb74171c7b56a23deccd75fe3abfe30d
Author: Vivien Malerba <malerba gnome-db org>
Date: Sun Sep 29 18:39:57 2013 +0200
Improved tests regarding providers handling of dates
tests/providers/check_postgres.c | 100 ++++++++++++++++
tests/providers/check_sqlite.c | 1 +
tests/providers/prov-test-common.c | 226 +++++++++++++++++++++++++++++++++++-
tests/providers/prov-test-common.h | 2 +
tests/providers/prov_dbstruct.xml | 5 +
tests/test-cnc-utils.c | 118 ++++++++++++--------
tests/test-cnc-utils.h | 1 +
7 files changed, 401 insertions(+), 52 deletions(-)
---
diff --git a/tests/providers/check_postgres.c b/tests/providers/check_postgres.c
index e244cab..fe3bad5 100644
--- a/tests/providers/check_postgres.c
+++ b/tests/providers/check_postgres.c
@@ -21,12 +21,18 @@
#define PROVIDER "PostgreSQL"
#include "prov-test-common.h"
+#include <sql-parser/gda-sql-parser.h>
+#include "../test-errors.h"
+
+#define CHECK_EXTRA_INFO 1
extern GdaProviderInfo *pinfo;
extern GdaConnection *cnc;
extern gboolean params_provided;
extern gboolean fork_tests;
+static int test_timestamp_change_format (void);
+
int
main (int argc, char **argv)
{
@@ -46,6 +52,8 @@ main (int argc, char **argv)
if (cnc) {
number_failed += prov_test_common_check_timestamp ();
+ number_failed += prov_test_common_check_date ();
+ number_failed += test_timestamp_change_format ();
number_failed += prov_test_common_check_meta ();
number_failed += prov_test_common_check_meta_identifiers (TRUE, TRUE);
number_failed += prov_test_common_check_meta_identifiers (TRUE, FALSE);
@@ -62,3 +70,95 @@ main (int argc, char **argv)
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
+static int
+test_timestamp_change_format (void)
+{
+ GdaSqlParser *parser = NULL;
+ GdaStatement *stmt = NULL;
+ GError *error = NULL;
+ int number_failed = 0;
+ GdaDataModel *model = NULL;
+ GValue *value = NULL;
+
+#ifdef CHECK_EXTRA_INFO
+ g_print ("\n============= %s() =============\n", __FUNCTION__);
+#endif
+
+ parser = gda_connection_create_parser (cnc);
+ if (!parser)
+ parser = gda_sql_parser_new ();
+
+ /* change date style */
+ stmt = gda_sql_parser_parse_string (parser, "SET datestyle to 'SQL'",
+ NULL, &error);
+ if (!stmt ||
+ (gda_connection_statement_execute_non_select (cnc, stmt, NULL, NULL, &error) == -1)) {
+ number_failed ++;
+ goto out;
+ }
+ g_print ("Changed datestyle to SQL\n");
+
+ /* Check that date format has changed */
+ GdaDataHandler *dh;
+ gchar *str, *estr;
+ GDate *date = NULL;
+ dh = gda_server_provider_get_data_handler_g_type (gda_connection_get_provider (cnc), cnc,
G_TYPE_DATE);
+ date = g_date_new_dmy (28, G_DATE_SEPTEMBER, 2013);
+ g_value_set_boxed ((value = gda_value_new (G_TYPE_DATE)), date);
+ g_date_free (date);
+ str = gda_data_handler_get_str_from_value (dh, value);
+ estr = "09/28/2013";
+ if (strcmp (str, estr)) {
+ g_set_error (&error, TEST_ERROR, TEST_ERROR_GENERIC,
+ "GdaDataHandler converted date to STR in an unexpected way: got '%s' and
expected '%s'", str, estr);
+ number_failed ++;
+ goto out;
+ }
+ g_free (str);
+
+ str = gda_data_handler_get_sql_from_value (dh, value);
+ estr = "'09/28/2013'";
+ if (strcmp (str, estr)) {
+ g_set_error (&error, TEST_ERROR, TEST_ERROR_GENERIC,
+ "GdaDataHandler converted date to SQL in an unexpected way: got '%s' and
expected '%s'", str, estr);
+ number_failed ++;
+ goto out;
+ }
+ g_free (str);
+
+ /* change date style */
+ stmt = gda_sql_parser_parse_string (parser, "SET datestyle to 'ISO'",
+ NULL, &error);
+ if (!stmt ||
+ (gda_connection_statement_execute_non_select (cnc, stmt, NULL, NULL, &error) == -1)) {
+ number_failed ++;
+ goto out;
+ }
+ g_print ("Changed datestyle to ISO\n");
+
+ /* Check that date format has changed */
+ str = gda_data_handler_get_str_from_value (dh, value);
+ estr = "2013-09-28";
+ if (strcmp (str, estr)) {
+ g_set_error (&error, TEST_ERROR, TEST_ERROR_GENERIC,
+ "GdaDataHandler converted date in an unexpected way: got '%s' and expected
'%s'", str, estr);
+ number_failed ++;
+ goto out;
+ }
+out:
+ if (value)
+ gda_value_free (value);
+ if (stmt)
+ g_object_unref (stmt);
+ g_object_unref (parser);
+
+#ifdef CHECK_EXTRA_INFO
+ g_print ("Date format test resulted in %d error(s)\n", number_failed);
+ if (number_failed != 0)
+ g_print ("error: %s\n", error && error->message ? error->message : "No detail");
+ if (error)
+ g_error_free (error);
+#endif
+
+ return number_failed;
+}
diff --git a/tests/providers/check_sqlite.c b/tests/providers/check_sqlite.c
index 8db20e3..d67345b 100644
--- a/tests/providers/check_sqlite.c
+++ b/tests/providers/check_sqlite.c
@@ -45,6 +45,7 @@ main (int argc, char **argv)
if (cnc) {
number_failed += prov_test_common_check_timestamp ();
+ number_failed += prov_test_common_check_date ();
number_failed += prov_test_common_check_meta ();
number_failed += prov_test_common_check_meta_identifiers (TRUE, TRUE);
number_failed += prov_test_common_check_meta_identifiers (TRUE, FALSE);
diff --git a/tests/providers/prov-test-common.c b/tests/providers/prov-test-common.c
index e3e6f4e..06dd5f3 100644
--- a/tests/providers/prov-test-common.c
+++ b/tests/providers/prov-test-common.c
@@ -83,6 +83,19 @@ prov_test_common_setup (void)
return number_failed;
}
+GdaConnection *
+prov_test_common_create_extra_connection (void)
+{
+ GdaConnection *cnc;
+ GError *lerror = NULL;
+ cnc = test_cnc_open_connection (pinfo->id, "testcheckdb", &lerror);
+ if (!cnc) {
+ g_print ("Error setting up connection: %s\n", lerror && lerror->message ? lerror->message :
"No detail");
+ g_clear_error (&lerror);
+ }
+ return cnc;
+}
+
/*
*
@@ -702,7 +715,7 @@ prov_test_common_check_data_select (void)
* Check that timezones are handled correctly when storing and retreiving timestamps
*/
static gboolean
-gda_timestamp_equal (const GValue *cv1, const GValue *cv2)
+timestamp_equal (const GValue *cv1, const GValue *cv2)
{
g_assert (G_VALUE_TYPE (cv1) == GDA_TYPE_TIMESTAMP);
g_assert (G_VALUE_TYPE (cv2) == GDA_TYPE_TIMESTAMP);
@@ -743,8 +756,7 @@ prov_test_common_check_timestamp (void)
tso = gda_value_new_timestamp_from_timet (time (NULL));
/* insert timestamp */
- stmt = gda_sql_parser_parse_string (parser, "INSERT INTO tstest (ts) VALUES (##ts::timestamp)",
- NULL, &error);
+ stmt = gda_sql_parser_parse_string (parser, "INSERT INTO tstest (ts) VALUES (##ts::timestamp)", NULL,
&error);
if (!stmt ||
! gda_statement_get_parameters (stmt, ¶ms, &error) ||
! gda_set_set_holder_value (params, &error, "ts", gda_value_get_timestamp (tso)) ||
@@ -756,8 +768,7 @@ prov_test_common_check_timestamp (void)
g_print ("Inserted TS %s\n", gda_value_stringify (tso));
/* retreive timestamp */
- stmt = gda_sql_parser_parse_string (parser, "SELECT ts FROM tstest",
- NULL, &error);
+ stmt = gda_sql_parser_parse_string (parser, "SELECT ts FROM tstest", NULL, &error);
if (!stmt) {
number_failed ++;
goto out;
@@ -782,7 +793,7 @@ prov_test_common_check_timestamp (void)
number_failed ++;
goto out;
}
- if (! gda_timestamp_equal (tso, cvalue)) {
+ if (! timestamp_equal (tso, cvalue)) {
gchar *tmpg, *tmpe;
tmpg = gda_value_stringify (cvalue);
tmpe = gda_value_stringify (tso);
@@ -794,6 +805,49 @@ prov_test_common_check_timestamp (void)
goto out;
}
+ /* check that data handler is correctly configured: compare the same timestamp rendered by a data
handler for
+ * timestamps with the date rendered as a string by the server (by appending a string to the
timestamp field) */
+ GdaDataHandler *dh;
+ dh = gda_server_provider_get_data_handler_g_type (gda_connection_get_provider (cnc), cnc,
GDA_TYPE_TIMESTAMP);
+ gchar *str;
+ str = gda_data_handler_get_str_from_value (dh, cvalue);
+ g_object_unref (model);
+
+ stmt = gda_sql_parser_parse_string (parser, "SELECT ts || 'asstring' FROM tstest", NULL, &error); /*
retreive timestamp as string */
+ if (!stmt) {
+ g_free (str);
+ number_failed ++;
+ goto out;
+ }
+
+ model = gda_connection_statement_execute_select (cnc, stmt, NULL, &error);
+ if (!model) {
+ g_free (str);
+ number_failed ++;
+ goto out;
+ }
+ gda_data_model_dump (model, NULL);
+ if (gda_data_model_get_n_rows (model) != 1) {
+ g_set_error (&error, TEST_ERROR, TEST_ERROR_GENERIC,
+ "Data model should have exactly 1 row");
+ g_free (str);
+ number_failed ++;
+ goto out;
+ }
+ cvalue = gda_data_model_get_typed_value_at (model, 0, 0, G_TYPE_STRING, FALSE, &error);
+ if (!cvalue) {
+ g_free (str);
+ number_failed ++;
+ goto out;
+ }
+ if (strncmp (str, g_value_get_string (cvalue), 10)) { /* only compare date parts */
+ g_set_error (&error, TEST_ERROR, TEST_ERROR_GENERIC,
+ "Returned GdaDataHandler returned wrong result: '%s' and expected '%s'", str,
g_value_get_string (cvalue));
+ g_free (str);
+ number_failed ++;
+ goto out;
+ }
+
out:
if (stmt)
g_object_unref (stmt);
@@ -813,3 +867,163 @@ out:
return number_failed;
}
+
+static GValue *
+value_new_date_from_timet (time_t val)
+{
+ GValue *value;
+ GDate *date;
+ date = g_date_new ();
+ g_date_set_time_t (date, val);
+
+ value = gda_value_new (G_TYPE_DATE);
+ g_value_set_boxed (value, date);
+ g_date_free (date);
+
+ return value;
+}
+
+static gboolean
+date_equal (const GValue *cv1, const GValue *cv2)
+{
+ g_assert (G_VALUE_TYPE (cv1) == G_TYPE_DATE);
+ g_assert (G_VALUE_TYPE (cv2) == G_TYPE_DATE);
+ const GDate *ts1, *ts2;
+ ts1 = (GDate*) g_value_get_boxed (cv1);
+ ts2 = (GDate*) g_value_get_boxed (cv2);
+ return g_date_compare (ts1, ts2) ? FALSE : TRUE;
+}
+
+int
+prov_test_common_check_date (void)
+{
+ GdaSqlParser *parser = NULL;
+ GdaStatement *stmt = NULL;
+ GdaSet *params = NULL;
+ GError *error = NULL;
+ int number_failed = 0;
+ GdaDataModel *model = NULL;
+
+#ifdef CHECK_EXTRA_INFO
+ g_print ("\n============= %s() =============\n", __FUNCTION__);
+#endif
+
+ parser = gda_connection_create_parser (cnc);
+ if (!parser)
+ parser = gda_sql_parser_new ();
+
+ GValue *tso;
+ tso = value_new_date_from_timet (time (NULL));
+
+ /* insert date */
+ stmt = gda_sql_parser_parse_string (parser, "INSERT INTO datetest (thedate) VALUES
(##thedate::date)", NULL, &error);
+ if (!stmt ||
+ ! gda_statement_get_parameters (stmt, ¶ms, &error) ||
+ ! gda_set_set_holder_value (params, &error, "thedate", (GDate*) g_value_get_boxed (tso)) ||
+ (gda_connection_statement_execute_non_select (cnc, stmt, params, NULL, &error) == -1)) {
+ number_failed ++;
+ goto out;
+ }
+
+ g_print ("Inserted date %s\n", gda_value_stringify (tso));
+
+ /* retreive date */
+ stmt = gda_sql_parser_parse_string (parser, "SELECT thedate FROM datetest", NULL, &error);
+ if (!stmt) {
+ number_failed ++;
+ goto out;
+ }
+
+ model = gda_connection_statement_execute_select (cnc, stmt, NULL, &error);
+ if (!model) {
+ number_failed ++;
+ goto out;
+ }
+ gda_data_model_dump (model, NULL);
+ if (gda_data_model_get_n_rows (model) != 1) {
+ g_set_error (&error, TEST_ERROR, TEST_ERROR_GENERIC,
+ "Data model should have exactly 1 row");
+ number_failed ++;
+ goto out;
+ }
+
+ const GValue *cvalue;
+ cvalue = gda_data_model_get_typed_value_at (model, 0, 0, G_TYPE_DATE, FALSE, &error);
+ if (!cvalue) {
+ number_failed ++;
+ goto out;
+ }
+ if (! date_equal (tso, cvalue)) {
+ gchar *tmpg, *tmpe;
+ tmpg = gda_value_stringify (cvalue);
+ tmpe = gda_value_stringify (tso);
+ g_set_error (&error, TEST_ERROR, TEST_ERROR_GENERIC,
+ "Retreived date differs from expected: got '%s' and expected '%s'", tmpg, tmpe);
+ g_free (tmpg);
+ g_free (tmpe);
+ number_failed ++;
+ goto out;
+ }
+
+ /* check that data handler is correctly configured: compare the same timestamp rendered by a data
handler for
+ * timestamps with the date rendered as a string by the server (by appending a string to the
timestamp field) */
+ GdaDataHandler *dh;
+ dh = gda_server_provider_get_data_handler_g_type (gda_connection_get_provider (cnc), cnc,
G_TYPE_DATE);
+ gchar *str;
+ str = gda_data_handler_get_str_from_value (dh, cvalue);
+ g_object_unref (model);
+
+ stmt = gda_sql_parser_parse_string (parser, "SELECT thedate || 'asstring' FROM datetest", NULL,
&error); /* retreive date as string */
+ if (!stmt) {
+ g_free (str);
+ number_failed ++;
+ goto out;
+ }
+
+ model = gda_connection_statement_execute_select (cnc, stmt, NULL, &error);
+ if (!model) {
+ g_free (str);
+ number_failed ++;
+ goto out;
+ }
+ gda_data_model_dump (model, NULL);
+ if (gda_data_model_get_n_rows (model) != 1) {
+ g_set_error (&error, TEST_ERROR, TEST_ERROR_GENERIC,
+ "Data model should have exactly 1 row");
+ g_free (str);
+ number_failed ++;
+ goto out;
+ }
+ cvalue = gda_data_model_get_typed_value_at (model, 0, 0, G_TYPE_STRING, FALSE, &error);
+ if (!cvalue) {
+ g_free (str);
+ number_failed ++;
+ goto out;
+ }
+ if (strncmp (str, g_value_get_string (cvalue), 10)) { /* only compare date parts */
+ g_set_error (&error, TEST_ERROR, TEST_ERROR_GENERIC,
+ "Returned GdaDataHandler returned wrong result: '%s' and expected '%s'", str,
g_value_get_string (cvalue));
+ g_free (str);
+ number_failed ++;
+ goto out;
+ }
+
+out:
+ if (stmt)
+ g_object_unref (stmt);
+ if (params)
+ g_object_unref (params);
+ if (model)
+ g_object_unref (model);
+ g_object_unref (parser);
+
+#ifdef CHECK_EXTRA_INFO
+ g_print ("Date test resulted in %d error(s)\n", number_failed);
+ if (number_failed != 0)
+ g_print ("error: %s\n", error && error->message ? error->message : "No detail");
+ if (error)
+ g_error_free (error);
+#endif
+
+ return number_failed;
+}
diff --git a/tests/providers/prov-test-common.h b/tests/providers/prov-test-common.h
index 0479e29..6407907 100644
--- a/tests/providers/prov-test-common.h
+++ b/tests/providers/prov-test-common.h
@@ -25,12 +25,14 @@
#include "prov-test-util.h"
int prov_test_common_setup (void);
+GdaConnection *prov_test_common_create_extra_connection (void);
int prov_test_common_load_data (void);
int prov_test_common_check_meta (void);
int prov_test_common_check_meta_identifiers (gboolean case_sensitive, gboolean update_all);
int prov_test_common_check_cursor_models (void);
int prov_test_common_check_data_select (void);
int prov_test_common_check_timestamp (void);
+int prov_test_common_check_date (void);
int prov_test_common_clean (void);
#endif
diff --git a/tests/providers/prov_dbstruct.xml b/tests/providers/prov_dbstruct.xml
index 6ee5ace..0f7e293 100644
--- a/tests/providers/prov_dbstruct.xml
+++ b/tests/providers/prov_dbstruct.xml
@@ -122,4 +122,9 @@
<column name="ts" type="timestamp"/>
</table>
+ <!-- testing dates -->
+ <table name="datetest">
+ <column name="thedate" type="date"/>
+ </table>
+
</schema>
diff --git a/tests/test-cnc-utils.c b/tests/test-cnc-utils.c
index 6aa4280..9b76d5f 100644
--- a/tests/test-cnc-utils.c
+++ b/tests/test-cnc-utils.c
@@ -87,33 +87,12 @@ prov_name_upcase (const gchar *prov_name)
return str;
}
-/*
- * Set up a connection.
- *
- * Optionnally the database can be created if the <upper_case_provider_name>_DBCREATE_PARAMS
- * environment variable exists. Examples are:
- * MYSQL_DBCREATE_PARAMS "HOST=localhost"
- * POSTGRESQL_DBCREATE_PARAMS "HOST=localhost;PORT=5432"
- * SQLITE_DBCREATE_PARAMS "DB_DIR=."
- * BERKELEY_DB_CNC_PARAMS "DB_NAME=gda_check_bdb.db"
- *
- * The connection is opened if the <upper_case_provider_name>_CNC_PARAMS environment variable exists.
- * For example:
- * MSACCESS_CNC_PARAMS "DB_DIR=/home/me/libgda/tests/providers;DB_NAME=gda_check_db"
- * ORACLE_CNC_PARAMS TNSNAME=//127.0.0.1
- *
- *
- * If the <upper_case_provider_name>_DBCREATE_PARAMS is supplied, then its contents can be used
- * to complement the <upper_case_provider_name>_CNC_PARAMS.
- *
- * Returns: a GdaConnection if no error occurred
- */
GdaConnection *
-test_cnc_setup_connection (const gchar *provider, const gchar *dbname, GError **error)
+test_cnc_open_connection (const gchar *provider, const gchar *dbname, GError **error)
{
GdaConnection *cnc = NULL;
gchar *str, *upname;
- const gchar *db_params, *cnc_params;
+ const gchar *cnc_params;
GdaProviderInfo *prov_info;
GdaQuarkList *db_quark_list = NULL, *cnc_quark_list = NULL;
gboolean db_created = FALSE;
@@ -127,28 +106,8 @@ test_cnc_setup_connection (const gchar *provider, const gchar *dbname, GError **
return NULL;
}
- /* create database if requested */
- upname = prov_name_upcase (prov_info->id);
- str = g_strdup_printf ("%s_DBCREATE_PARAMS", upname);
- db_params = getenv (str);
- g_free (str);
- if (db_params) {
- GdaServerOperation *op;
-
- db_quark_list = gda_quark_list_new_from_string (db_params);
- op = gda_server_operation_prepare_drop_database (prov_info->id, dbname, NULL);
- gda_quark_list_foreach (db_quark_list, (GHFunc) db_create_quark_foreach_func, op);
- gda_server_operation_perform_drop_database (op, NULL, NULL);
- g_object_unref (op);
-
- op = gda_server_operation_prepare_create_database (prov_info->id, dbname, NULL);
- gda_quark_list_foreach (db_quark_list, (GHFunc) db_create_quark_foreach_func, op);
- if (!gda_server_operation_perform_create_database (op, NULL, error))
- goto out;
- db_created = TRUE;
- }
-
/* open connection to database */
+ upname = prov_name_upcase (prov_info->id);
str = g_strdup_printf ("%s_CNC_PARAMS", upname);
cnc_params = getenv (str);
g_free (str);
@@ -214,12 +173,79 @@ test_cnc_setup_connection (const gchar *provider, const gchar *dbname, GError **
if (cnc_quark_list)
gda_quark_list_free (cnc_quark_list);
- out:
- if (!db_params && !cnc_params)
+ if (!cnc_params)
g_set_error (error, TEST_ERROR, TEST_ERROR_GENERIC,
"Connection parameters not specified, test not executed (define %s_CNC_PARAMS or
%s_DBCREATE_PARAMS to create a test DB)\n", upname, upname);
g_free (upname);
+ return cnc;
+}
+
+/*
+ * Set up a connection.
+ *
+ * Optionnally the database can be created if the <upper_case_provider_name>_DBCREATE_PARAMS
+ * environment variable exists. Examples are:
+ * MYSQL_DBCREATE_PARAMS "HOST=localhost"
+ * POSTGRESQL_DBCREATE_PARAMS "HOST=localhost;PORT=5432"
+ * SQLITE_DBCREATE_PARAMS "DB_DIR=."
+ * BERKELEY_DB_CNC_PARAMS "DB_NAME=gda_check_bdb.db"
+ *
+ * The connection is opened if the <upper_case_provider_name>_CNC_PARAMS environment variable exists.
+ * For example:
+ * MSACCESS_CNC_PARAMS "DB_DIR=/home/me/libgda/tests/providers;DB_NAME=gda_check_db"
+ * ORACLE_CNC_PARAMS TNSNAME=//127.0.0.1
+ *
+ *
+ * If the <upper_case_provider_name>_DBCREATE_PARAMS is supplied, then its contents can be used
+ * to complement the <upper_case_provider_name>_CNC_PARAMS.
+ *
+ * Returns: a GdaConnection if no error occurred
+ */
+GdaConnection *
+test_cnc_setup_connection (const gchar *provider, const gchar *dbname, GError **error)
+{
+ GdaConnection *cnc = NULL;
+ gchar *str, *upname;
+ const gchar *db_params, *cnc_params;
+ GdaProviderInfo *prov_info;
+ GdaQuarkList *db_quark_list = NULL, *cnc_quark_list = NULL;
+ gboolean db_created = FALSE;
+
+ g_return_val_if_fail (dbname && *dbname, NULL);
+
+ prov_info = gda_config_get_provider_info (provider);
+ if (!prov_info) {
+ g_set_error (error, TEST_ERROR, TEST_ERROR_GENERIC,
+ "Provider '%s' not found", provider);
+ return NULL;
+ }
+
+ /* create database if requested */
+ upname = prov_name_upcase (prov_info->id);
+ str = g_strdup_printf ("%s_DBCREATE_PARAMS", upname);
+ db_params = getenv (str);
+ g_free (str);
+ if (db_params) {
+ GdaServerOperation *op;
+
+ db_quark_list = gda_quark_list_new_from_string (db_params);
+ op = gda_server_operation_prepare_drop_database (prov_info->id, dbname, NULL);
+ gda_quark_list_foreach (db_quark_list, (GHFunc) db_create_quark_foreach_func, op);
+ gda_server_operation_perform_drop_database (op, NULL, NULL);
+ g_object_unref (op);
+
+ op = gda_server_operation_prepare_create_database (prov_info->id, dbname, NULL);
+ gda_quark_list_foreach (db_quark_list, (GHFunc) db_create_quark_foreach_func, op);
+ if (!gda_server_operation_perform_create_database (op, NULL, error))
+ goto out;
+ db_created = TRUE;
+ }
+
+ /* open connection to database */
+ cnc = test_cnc_open_connection (provider, dbname, error);
+
+ out:
if (cnc) {
g_object_set_data_full (G_OBJECT (cnc), "dbname", g_strdup (dbname), g_free);
g_object_set_data (G_OBJECT (cnc), "db_created", GINT_TO_POINTER (db_created));
diff --git a/tests/test-cnc-utils.h b/tests/test-cnc-utils.h
index 18745c6..715b7f4 100644
--- a/tests/test-cnc-utils.h
+++ b/tests/test-cnc-utils.h
@@ -23,6 +23,7 @@
#include <libgda/libgda.h>
GdaConnection *test_cnc_setup_connection (const gchar *provider, const gchar *dbname, GError **error);
+GdaConnection *test_cnc_open_connection (const gchar *provider, const gchar *dbname, GError **error);
gboolean test_cnc_setup_db_structure (GdaConnection *cnc, const gchar *schema_file, GError **error);
gboolean test_cnc_setup_db_contents (GdaConnection *cnc, const gchar *data_file, GError **error);
gboolean test_cnc_clean_connection (GdaConnection *cnc, GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]