merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 514f92a9169d70113f2e189bd3d5f8e83034d3a9
parent e5fd06914800c3a8f0eb8f9af91f94d1c09deaa5
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date:   Thu, 28 Apr 2016 11:40:40 +0200

configuration file for testcase + "run()" function for it

Diffstat:
Msrc/backend/taler-merchant-httpd_pay.c | 1-
Msrc/backenddb/Makefile.am | 29++++++++++++++++++-----------
Asrc/backenddb/test-merchantdb-postgres.conf | 5+++++
Msrc/backenddb/test_merchantdb.c | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 89 insertions(+), 12 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c @@ -30,7 +30,6 @@ #include "taler-merchant-httpd_responses.h" #include "taler-merchant-httpd_auditors.h" #include "taler-merchant-httpd_exchanges.h" -#include "taler_merchantdb_lib.h" /** diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am @@ -40,14 +40,21 @@ libtaler_plugin_merchantdb_postgres_la_LDFLAGS = \ -lgnunetpostgres \ -lgnunetutil $(XLIB) -#check_PROGRAMS = \ -# test-merchantdb-postgres -# -#test_merchantdb_postgres_SOURCES = \ -# test_merchantdb.c -# -#test_merchantdb_postgres_LDADD = \ -# # TODO -# -#TESTS = \ -# test-merchantdb-postgres +if HAVE_POSTGRESQL +if HAVE_GNUNETPQ +check_PROGRAMS = \ + test-merchantdb-postgres +endif +endif + +test_merchantdb_postgres_SOURCES = \ + test_merchantdb.c + +test_merchantdb_postgres_LDFLAGS = \ + -lgnunetutil + +test_merchantdb_postgres_LDADD = \ + $(top_srcdir)/src/backenddb/libtalermerchantdb.la + +TESTS = \ + test-merchantdb-postgres diff --git a/src/backenddb/test-merchantdb-postgres.conf b/src/backenddb/test-merchantdb-postgres.conf @@ -0,0 +1,5 @@ +[merchant] +DB = postgres + +[merchantdb-postgres] +CONFIG = postges:///talertest diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c @@ -18,3 +18,69 @@ * @brief testcase for merchant's postgres db plugin * @author Marcello Stanisci */ + +#include "platform.h" +#include <taler/taler_util.h> +#include "taler_merchantdb_lib.h" + +static int result; +static struct TALER_EXCHANGEDB_Plugin *plugin; + +/** + * Main function that will be run by the scheduler. + * + * @param cls closure with config + */ +static void +run (void *cls) +{ + struct GNUNET_CONFIGURATION_Handle *cfg = cls; + + if (NULL == + (plugin = TALER_MERCHANTDB_plugin_load (cfg))) + { + result = 1; + return; + } +} + +int +main (int argc, + char *const argv[]) +{ + + const char *plugin_name; + char *config_filename; + char *testname; + struct GNUNET_CONFIGURATION_Handle *cfg; + + result = -1; + if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) + { + GNUNET_break (0); + return -1; + } + GNUNET_log_setup (argv[0], + "WARNING", + NULL); + plugin_name++; + (void) GNUNET_asprintf (&testname, + "test-merchantdb-%s", plugin_name); + (void) GNUNET_asprintf (&config_filename, + "%s.conf", testname); + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_OK != + GNUNET_CONFIGURATION_parse (cfg, + config_filename)) + { + GNUNET_break (0); + GNUNET_free (config_filename); + GNUNET_free (testname); + return 2; + } + GNUNET_SCHEDULER_run (&run, cfg); + GNUNET_CONFIGURATION_destroy (cfg); + GNUNET_free (config_filename); + GNUNET_free (testname); + return result; +}