| 1 | Taken from upstream.
|
| 2 |
|
| 3 | From b0cd77e588620465b78f7c017d3f240e13936aa3 Mon Sep 17 00:00:00 2001
|
| 4 | From: Pavlo Solntsev <[email protected]>
|
| 5 | Date: Sun, 19 Sep 2021 22:51:38 -0500
|
| 6 | Subject: [PATCH] Test: Skip test if no server available
|
| 7 |
|
| 8 | Two variables will be checked. If they set
|
| 9 | and provide all needed information the test
|
| 10 | will be executed. If they are not set, the test
|
| 11 | will return TRUE and will terminate with
|
| 12 | termination status EXIT_SUCCESS.
|
| 13 | ---
|
| 14 | tests/db/check-db-catalog-postgresql.c | 16 ++++++++++++++++
|
| 15 | tests/test-server-operation-postgresql.c | 16 ++++++++++++++++
|
| 16 | 2 files changed, 32 insertions(+)
|
| 17 |
|
| 18 | diff --git a/tests/db/check-db-catalog-postgresql.c b/tests/db/check-db-catalog-postgresql.c
|
| 19 | index 5b8e9395c..bf9a8942c 100644
|
| 20 | |
| 21 | |
| 22 | @@ -25,6 +25,9 @@
|
| 23 | #include <libgda/libgda.h>
|
| 24 | #include "../test-cnc-utils.h"
|
| 25 |
|
| 26 | +#define PROVIDER_DB_CREATE_PARAMS "POSTGRESQL_DBCREATE_PARAMS"
|
| 27 | +#define PROVIDER_CNC_PARAMS "POSTGRESQL_CNC_PARAMS"
|
| 28 | +
|
| 29 | typedef struct {
|
| 30 | GdaDbCatalog *catalog;
|
| 31 | GdaConnection *cnc;
|
| 32 | @@ -359,6 +362,19 @@ main (gint argc,
|
| 33 | {
|
| 34 | setlocale (LC_ALL,"");
|
| 35 |
|
| 36 | + const gchar *db_create_str;
|
| 37 | + const gchar *cnc_params;
|
| 38 | +
|
| 39 | + db_create_str = g_getenv (PROVIDER_DB_CREATE_PARAMS);
|
| 40 | + cnc_params = g_getenv (PROVIDER_CNC_PARAMS);
|
| 41 | +
|
| 42 | + if (!db_create_str || !cnc_params) {
|
| 43 | + g_print ("Please set POSTGRESQL_DBCREATE_PARAMS and POSTGRESQL_CNC_PARAMS variable"
|
| 44 | + "with dbname, host, user and port (usually 5432)\n");
|
| 45 | + g_print ("Test will not be performed\n");
|
| 46 | + return EXIT_SUCCESS;
|
| 47 | + }
|
| 48 | +
|
| 49 | g_test_init (&argc,&argv,NULL);
|
| 50 |
|
| 51 | g_test_add ("/test-db-postgresql/meta-tables",
|
| 52 | diff --git a/tests/test-server-operation-postgresql.c b/tests/test-server-operation-postgresql.c
|
| 53 | index 37796c4be..860f41a18 100644
|
| 54 | |
| 55 | |
| 56 | @@ -38,9 +38,12 @@
|
| 57 | #include <glib/gi18n.h>
|
| 58 | #include <locale.h>
|
| 59 | #include <libgda/libgda.h>
|
| 60 | +/*#include <stdlib.h>*/
|
| 61 | #include "test-cnc-utils.h"
|
| 62 |
|
| 63 | #define PROVIDER_NAME "PostgreSQL"
|
| 64 | +#define PROVIDER_DB_CREATE_PARAMS "POSTGRESQL_DBCREATE_PARAMS"
|
| 65 | +#define PROVIDER_CNC_PARAMS "POSTGRESQL_CNC_PARAMS"
|
| 66 |
|
| 67 | #define GDA_PGSQL_ERROR_HANDLE(e) (g_print("Error: %s: %s\n", G_STRLOC, e && e->message ? e->message : "No default"));
|
| 68 |
|
| 69 | @@ -1335,6 +1338,19 @@ main(gint argc, gchar *argv[])
|
| 70 | {
|
| 71 | setlocale (LC_ALL,"");
|
| 72 |
|
| 73 | + const gchar *db_create_str;
|
| 74 | + const gchar *cnc_params;
|
| 75 | +
|
| 76 | + db_create_str = g_getenv (PROVIDER_DB_CREATE_PARAMS);
|
| 77 | + cnc_params = g_getenv (PROVIDER_CNC_PARAMS);
|
| 78 | +
|
| 79 | + if (!db_create_str || !cnc_params) {
|
| 80 | + g_print ("Please set POSTGRESQL_DBCREATE_PARAMS and POSTGRESQL_CNC_PARAMS variable"
|
| 81 | + "with dbname, host, user and port (usually 5432)\n");
|
| 82 | + g_print ("Test will not be performed\n");
|
| 83 | + return EXIT_SUCCESS;
|
| 84 | + }
|
| 85 | +
|
| 86 | g_test_init (&argc,&argv,NULL);
|
| 87 |
|
| 88 | g_test_add ("/test-server-operation-sqlite/old-so-module",
|
| 89 | --
|
| 90 | GitLab
|
| 91 |
|