[libgda: 4/6] Test was updated to include fkey operation
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda: 4/6] Test was updated to include fkey operation
- Date: Mon, 8 Oct 2018 16:18:17 +0000 (UTC)
commit 10ec4979669badb05a2b4331a0cda0c67a4dcd80
Author: Pavlo Solntsev <p sun fun gmail com>
Date: Tue Sep 25 22:40:42 2018 -0500
Test was updated to include fkey operation
tests/ddl/check-ddl-db-create.c | 76 ++++++++++++++++++++++++++++++++++++-----
tests/ddl/check_db.xml | 4 +--
2 files changed, 69 insertions(+), 11 deletions(-)
---
diff --git a/tests/ddl/check-ddl-db-create.c b/tests/ddl/check-ddl-db-create.c
index 9b03a0247..15fa10926 100644
--- a/tests/ddl/check-ddl-db-create.c
+++ b/tests/ddl/check-ddl-db-create.c
@@ -59,23 +59,23 @@ test_ddl_db_create_start(CheckCreatedb *self,
self->creator = gda_ddl_creator_new();
- self->cnc = gda_connection_new_from_string("SQLite",
- "DB_DIR=.;DB_NAME=ddl_test_create",
- NULL,
- GDA_CONNECTION_OPTIONS_NONE,
- NULL);
+ self->cnc = gda_connection_new_from_string ("SQLite",
+ "DB_DIR=.;DB_NAME=ddl_test_create",
+ NULL,
+ GDA_CONNECTION_OPTIONS_NONE,
+ NULL);
g_assert_nonnull (self->cnc);
- gboolean res = gda_connection_open(self->cnc,NULL);
+ gboolean res = gda_connection_open (self->cnc,NULL);
g_assert_true (res);
res = gda_ddl_creator_validate_file_from_path (self->xmlfile,NULL);
g_assert_true (res);
- res = gda_ddl_creator_parse_file_from_path(self->creator,
- self->xmlfile,
- NULL);
+ res = gda_ddl_creator_parse_file_from_path (self->creator,
+ self->xmlfile,
+ NULL);
g_assert_true (res);
@@ -89,6 +89,26 @@ static void
test_ddl_db_create_finish (CheckCreatedb *self,
gconstpointer user_data)
{
+/* Dropping all tables */
+ GdaServerOperation *op = gda_connection_create_operation (self->cnc,
+ GDA_SERVER_OPERATION_DROP_TABLE,
+ NULL,
+ NULL);
+
+ g_assert_true (op);
+
+ gboolean res = gda_server_operation_set_value_at (op,"employee",NULL,"/TABLE_DESC_P/TABLE_NAME");
+ g_assert_true (res);
+ res = gda_connection_perform_operation (self->cnc,op,NULL);
+ g_assert_true (res);
+
+ res = gda_server_operation_set_value_at (op,"job_site",NULL,"/TABLE_DESC_P/TABLE_NAME");
+ g_assert_true (res);
+ res = gda_connection_perform_operation (self->cnc,op,NULL);
+ g_assert_true (res);
+
+ g_object_unref (op);
+
gda_connection_close (self->cnc, NULL);
g_free (self->xmlfile);
g_object_unref (self->creator);
@@ -99,7 +119,45 @@ static void
test_ddl_db_create_test1 (CheckCreatedb *self,
gconstpointer user_data)
{
+ GValue *value_name = gda_value_new (G_TYPE_STRING);
+
+ g_value_set_string (value_name,"John");
+
+ GValue *value_id = gda_value_new (G_TYPE_INT);
+
+ GError *error = NULL;
+
+ gboolean res = gda_connection_insert_row_into_table (self->cnc,"job_site",&error,
+ "name",value_name,
+ NULL);
+ g_assert_true (res);
+
+ g_value_set_string (value_name,"Tom");
+
+ res = gda_connection_insert_row_into_table (self->cnc,"job_site",NULL,
+ "name",value_name,
+ NULL);
+ g_assert_true (res);
+
+ g_value_set_int (value_id,2);
+
+ res = gda_connection_insert_row_into_table (self->cnc,"employee",NULL,
+ "job_site_id",value_id,
+ NULL);
+ g_assert_true (res);
+
+/* Try to insert wrong data
+ * There is no job_site record with id == 3
+ */
+ g_value_set_int (value_id,3);
+
+ res = gda_connection_insert_row_into_table (self->cnc,"employee",NULL,
+ "job_site_id",value_id,
+ NULL);
+ g_assert_false (res);
+ gda_value_free (value_id);
+ gda_value_free (value_name);
}
gint
diff --git a/tests/ddl/check_db.xml b/tests/ddl/check_db.xml
index 67f47f276..2e5c79b07 100644
--- a/tests/ddl/check_db.xml
+++ b/tests/ddl/check_db.xml
@@ -3,7 +3,7 @@
<schema>
<table name="employee">
<column name="id" type="int" pkey="TRUE"
- unique="TRUE" nnul="TRUE" autoinc="FALSE">
+ unique="TRUE" nnul="TRUE" autoinc="TRUE">
</column>
<column name="job_site_id" type="int" nnul="TRUE">
</column>
@@ -13,7 +13,7 @@
</table>
<table name="job_site">
<column name="id" type="int" pkey="TRUE"
- unique="TRUE" nnul="TRUE" autoinc="FALSE">
+ unique="TRUE" nnul="TRUE" autoinc="TRUE" >
</column>
<column name="name" type="string">
<value size="20"></value>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]