gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: test template


From: gnunet
Subject: [taler-merchant] branch master updated: test template
Date: Fri, 18 Nov 2022 11:56:32 +0100

This is an automated email from the git hooks/post-receive script.

priscilla-huang pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new c159ab6e test template
c159ab6e is described below

commit c159ab6ea750b081d5f185e24579537136c1f156
Author: priscilla <priscilla.huang@efrei.net>
AuthorDate: Fri Nov 18 05:56:17 2022 -0500

    test template
---
 src/backenddb/test_merchantdb.c | 259 +++++++++++++++++++++-------------------
 1 file changed, 133 insertions(+), 126 deletions(-)

diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 3feeb03e..213b0794 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -6833,125 +6833,7 @@ test_kyc (void)
 }
 
 
-/**
- * Function that runs all tests.
- *
- * @return 0 on success, 1 otherwise.
- */
-static int
-run_tests (void)
-{
-  TEST_RET_ON_FAIL (test_instances ());
-  TEST_RET_ON_FAIL (test_products ());
-  TEST_RET_ON_FAIL (test_orders ());
-  TEST_RET_ON_FAIL (test_deposits ());
-  TEST_RET_ON_FAIL (test_transfers ());
-  TEST_RET_ON_FAIL (test_tips ());
-  TEST_RET_ON_FAIL (test_refunds ());
-  TEST_RET_ON_FAIL (test_lookup_orders_all_filters ());
-  TEST_RET_ON_FAIL (test_kyc ());
-  return 0;
-}
-
-
-/**
- * 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;
-  /* Data for 'store_payment()' */
-
-  /* Drop the tables to cleanup anything that might cause issues */
-  if (NULL == (plugin = TALER_MERCHANTDB_plugin_load (cfg)))
-  {
-    result = 77;
-    return;
-  }
-  (void) plugin->drop_tables (plugin->cls);
-  if (GNUNET_OK !=
-      plugin->create_tables (plugin->cls))
-  {
-    result = 77;
-    return;
-  }
-  if (GNUNET_OK !=
-      plugin->connect (plugin->cls))
-  {
-    result = 17;
-    return;
-  }
-
-  /* Run the preflight */
-  plugin->preflight (plugin->cls);
-
-  result = run_tests ();
-        if (0 == result)
-  result = run_template_tests ();
-        if (0 == result)
-  {
-    /* Test dropping tables */
-    if (GNUNET_OK != plugin->drop_tables (plugin->cls))
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Dropping tables failed\n");
-      result = 77;
-      return;
-    }
-  }
 
-  TALER_MERCHANTDB_plugin_unload (plugin);
-  plugin = NULL;
-}
-
-
-/**
- * Entry point for the tests.
- */
-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], "DEBUG", 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;
-}
 
 
 /* *********** Templates ********** */
@@ -7013,7 +6895,7 @@ free_template_data (struct TemplateData *template)
  * @return 0 on equality, 1 otherwise.
  */
 static int
-check_template_equal (const struct TALER_MERCHANTDB_TemplateDetails *a,
+check_templates_equal (const struct TALER_MERCHANTDB_TemplateDetails *a,
                       const struct TALER_MERCHANTDB_TemplateDetails *b)
 {
   if ((0 != strcmp (a->template_description,
@@ -7021,7 +6903,7 @@ check_template_equal (const struct 
TALER_MERCHANTDB_TemplateDetails *a,
       (0 != strcmp (a->image,
                     b->image)) ||
       (1 != json_equal (a->template_contract,
-                        b->template_contract))
+                        b->template_contract)))
     return 1;
   return 0;
 }
@@ -7118,7 +7000,7 @@ struct TestLookupTemplates_Closure
   /**
    * Number of template ids to compare to
    */
-  unsigned int template_to_cmp_length;
+  unsigned int templates_to_cmp_length;
 
   /**
    * Pointer to array of template ids
@@ -7145,7 +7027,8 @@ struct TestLookupTemplates_Closure
  */
 static void
 lookup_templates_cb (void *cls,
-                    const char *template_id)
+                     const char *template_id,
+                     const char *template_description)
 {
   struct TestLookupTemplates_Closure *cmp = cls;
   if (NULL == cmp)
@@ -7291,11 +7174,8 @@ post_test_templates (struct TestTemplates_Closure *cls)
  * @return 0 on success, 1 otherwise.
  */
 static int
-run_test_templates (struct TestProducts_Closure *cls)
+run_test_templates (struct TestTemplates_Closure *cls)
 {
-  struct GNUNET_Uuid uuid;
-  struct GNUNET_TIME_Timestamp refund_deadline =
-    GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_WEEKS);
 
   /* Test that insert without an instance fails */
   TEST_RET_ON_FAIL (test_insert_template (&cls->instance,
@@ -7362,6 +7242,8 @@ run_test_templates (struct TestProducts_Closure *cls)
   TEST_RET_ON_FAIL (test_lookup_templates (&cls->instance,
                                           1,
                                           cls->templates));
+  return 0;
+}
 
 
 /**
@@ -7379,5 +7261,130 @@ test_templates (void)
   return test_result;
 }
 
+/**
+ * Function that runs all tests.
+ *
+ * @return 0 on success, 1 otherwise.
+ */
+static int
+run_tests (void)
+{
+  TEST_RET_ON_FAIL (test_instances ());
+  TEST_RET_ON_FAIL (test_products ());
+  TEST_RET_ON_FAIL (test_orders ());
+  TEST_RET_ON_FAIL (test_deposits ());
+  TEST_RET_ON_FAIL (test_transfers ());
+  TEST_RET_ON_FAIL (test_tips ());
+  TEST_RET_ON_FAIL (test_refunds ());
+  TEST_RET_ON_FAIL (test_lookup_orders_all_filters ());
+  TEST_RET_ON_FAIL (test_kyc ());
+  TEST_RET_ON_FAIL (test_templates ());
+  return 0;
+}
+
+
+
+/**
+ * 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;
+  /* Data for 'store_payment()' */
+
+  /* Drop the tables to cleanup anything that might cause issues */
+  if (NULL == (plugin = TALER_MERCHANTDB_plugin_load (cfg)))
+  {
+    result = 77;
+    return;
+  }
+  (void) plugin->drop_tables (plugin->cls);
+  if (GNUNET_OK !=
+      plugin->create_tables (plugin->cls))
+  {
+    result = 77;
+    return;
+  }
+  if (GNUNET_OK !=
+      plugin->connect (plugin->cls))
+  {
+    result = 17;
+    return;
+  }
+
+  /* Run the preflight */
+  plugin->preflight (plugin->cls);
+
+  result = run_tests ();
+        if (0 == result)
+          /** result = run_test_templates ();
+              if (0 == result)*/
+  {
+    /* Test dropping tables */
+    if (GNUNET_OK != plugin->drop_tables (plugin->cls))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Dropping tables failed\n");
+      result = 77;
+      return;
+    }
+  }
+
+  TALER_MERCHANTDB_plugin_unload (plugin);
+  plugin = NULL;
+}
+
+
+
+
+/**
+ * Entry point for the tests.
+ */
+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], "DEBUG", 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;
+}
+
+
 
 /* end of test_merchantdb.c */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]