[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated: fix backend-db test
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated: fix backend-db test |
Date: |
Sat, 17 Apr 2021 21:52:23 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new 90eec618 fix backend-db test
90eec618 is described below
commit 90eec618406ba4e664b228d4f6e03c5e2803c106
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Apr 17 21:52:21 2021 +0200
fix backend-db test
---
src/backenddb/test_merchantdb.c | 39 +++++++++-----------------------------
src/include/taler_merchantdb_lib.h | 5 +++--
2 files changed, 12 insertions(+), 32 deletions(-)
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index be07c3cf..dd32e652 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -701,25 +701,6 @@ test_instances (void)
/* *********** Products ********** */
-/**
- * Frees memory associated with a product.
- *
- * @param pd the product containing the memory to free.
- */
-static void
-free_product (struct TALER_MERCHANTDB_ProductDetails *pd)
-{
- GNUNET_free (pd->description);
- if (NULL != pd->description_i18n)
- json_decref (pd->description_i18n);
- GNUNET_free (pd->unit);
- if (NULL != pd->image)
- json_decref (pd->image);
- if (NULL != pd->address)
- json_decref (pd->address);
-}
-
-
/**
* A container for data relevant to a product.
*/
@@ -760,7 +741,7 @@ make_product (const char *id,
product->product.total_stock = 55;
product->product.total_sold = 0;
product->product.total_lost = 0;
- product->product.image = json_array ();
+ product->product.image = GNUNET_strdup ("");
GNUNET_assert (NULL != product->product.image);
product->product.address = json_array ();
GNUNET_assert (NULL != product->product.address);
@@ -778,7 +759,7 @@ free_product_data (struct ProductData *product)
{
json_decref (product->product.description_i18n);
json_decref (product->product.taxes);
- json_decref (product->product.image);
+ GNUNET_free (product->product.image);
json_decref (product->product.address);
}
@@ -809,8 +790,8 @@ check_products_equal (const struct
TALER_MERCHANTDB_ProductDetails *a,
(a->total_stock != b->total_stock) ||
(a->total_sold != b->total_sold) ||
(a->total_lost != b->total_lost) ||
- (1 != json_equal (a->image,
- b->image)) ||
+ (0 != strcmp (a->image,
+ b->image)) ||
(1 != json_equal (a->address,
b->address)) ||
(a->next_restock.abs_value_us != b->next_restock.abs_value_us))
@@ -884,7 +865,7 @@ test_lookup_product (const struct InstanceData *instance,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Lookup product failed\n");
- free_product (&lookup_result);
+ TALER_MERCHANTDB_product_details_free (&lookup_result);
return 1;
}
const struct TALER_MERCHANTDB_ProductDetails *to_cmp = &product->product;
@@ -893,10 +874,10 @@ test_lookup_product (const struct InstanceData *instance,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Lookup product failed: incorrect product returned\n");
- free_product (&lookup_result);
+ TALER_MERCHANTDB_product_details_free (&lookup_result);
return 1;
}
- free_product (&lookup_result);
+ TALER_MERCHANTDB_product_details_free (&lookup_result);
return 0;
}
@@ -1141,10 +1122,8 @@ run_test_products (struct TestProducts_Closure *cls)
cls->products[0].product.total_stock = 100;
cls->products[0].product.total_sold = 10;
cls->products[0].product.total_lost = 7;
- GNUNET_assert (0 ==
- json_array_append_new (cls->products[0].product.image,
- json_string (
-
"http://some-website.com/image.png")));
+ GNUNET_free (cls->products[0].product.image);
+ cls->products[0].product.image = GNUNET_strdup ("image");
GNUNET_assert (0 ==
json_array_append_new (cls->products[0].product.address,
json_string ("444 Some Street")));
diff --git a/src/include/taler_merchantdb_lib.h
b/src/include/taler_merchantdb_lib.h
index 35fb5c12..a3e6394e 100644
--- a/src/include/taler_merchantdb_lib.h
+++ b/src/include/taler_merchantdb_lib.h
@@ -55,8 +55,9 @@ TALER_MERCHANTDB_plugin_unload (struct
TALER_MERCHANTDB_Plugin *dbh);
* @param[in] pd product details to clean up
*/
void
-TALER_MERCHANTDB_product_details_free (struct
- TALER_MERCHANTDB_ProductDetails *pd);
+TALER_MERCHANTDB_product_details_free (
+ struct
+ TALER_MERCHANTDB_ProductDetails *pd);
#endif /* MERCHANT_DB_H */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant] branch master updated: fix backend-db test,
gnunet <=