[libgda] meta-store: setup tests for PostgreSQL



commit 80024b7959b578c4f2f682425fe5ede0a0d02451
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Oct 10 14:29:49 2018 -0500

    meta-store: setup tests for PostgreSQL
    
    This requires to have a database 'test', owned by 'test' role with password 'test1'

 tests/meta-store/check_meta_store_postgresql.c | 27 +++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/tests/meta-store/check_meta_store_postgresql.c b/tests/meta-store/check_meta_store_postgresql.c
index f89cbb4fc..230739bd7 100644
--- a/tests/meta-store/check_meta_store_postgresql.c
+++ b/tests/meta-store/check_meta_store_postgresql.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2008 - 2011 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2018 Daniel Espinosa <esodan gmail com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -23,36 +24,44 @@
 int 
 main(int argc, char ** argv)
 {
+       GdaConnection *cnc;
        GdaMetaStore *store;
        gchar *cnc_string;
-       
+       GError *error = NULL;
+
        gda_init ();
 
-       /* connection parameters */
-       cnc_string = getenv ("POSTGRESQL_META_CNC");
-       if (!cnc_string) {
-               g_print ("Postgres test not run, please set the POSTGRESQL_META_CNC environment variable \n"
-                       "For example 'DB_NAME=meta'\n");
+       cnc_string = "DB_NAME=test;HOST=localhost;USERNAME=test;PASSWORD=test1";
+       /* connection try */
+       cnc = gda_connection_open_from_string ("PostgreSQL", cnc_string, NULL, GDA_CONNECTION_OPTIONS_NONE, 
&error);
+       if (cnc == NULL) {
+               if (error) {
+                       g_print ("Connection no stablished. Error: %s\n", error->message);
+                       g_error_free (error);
+               }
+               g_print ("Postgres test not run, please setup a database 'test', owned by 'test' role with 
password 'test1' at localhost\n");
+               g_print ("Test Skip.\n");
                return EXIT_SUCCESS;
        }
-       
+       g_object_unref (cnc);
        /* Clean eveything which might exist in the store */
        gchar *str;
        str = g_strdup_printf ("PostgreSQL://%s", cnc_string);
        store = gda_meta_store_new (str);
        common_drop_all_tables (store);
        g_object_unref (store);
-       
+
        /* Test store setup */
        store = gda_meta_store_new (str);
        g_free (str);
 
        g_print ("STORE: %p, version: %d\n", store, store ? gda_meta_store_get_version (store) : 0);
 
+
        /* Tests */
        tests_group_1 (store);
        g_object_unref (store);
-       
+
        g_print ("Test Ok.\n");
        
        return EXIT_SUCCESS;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]