git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 7/7] t-reftable-merged: add test for REFTABLE_FORMAT_ERROR

From
CPChandra Pratap <chandrapratap3519@gmail.com>
Date
Jul 9, 2024, 05:28 UTC
Message-ID
<20240709053847.4453-8-chandrapratap3519@gmail.com>
In-Reply-To
<20240709053847.4453-1-chandrapratap3519@gmail.com>

When calling reftable_new_merged_table(), if the hash ID of the passsed reftable_table parameter doesn't match the passed hash_id parameter, a REFTABLE_FORMAT_ERROR is thrown. This case is currently left unexercised, so add a test for the same.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
---
 t/unit-tests/t-reftable-merged.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/t/unit-tests/t-reftable-merged.c b/t/unit-tests/t-reftable-merged.c
index e0054e379e..50047aa90b 100644
--- a/t/unit-tests/t-reftable-merged.c
+++ b/t/unit-tests/t-reftable-merged.c
@@ -11,6 +11,7 @@ license that can be found in the LICENSE file or at
 #include "reftable/constants.h"
 #include "reftable/merged.h"
 #include "reftable/reader.h"
+#include "reftable/reftable-error.h"
 #include "reftable/reftable-generic.h"
 #include "reftable/reftable-merged.h"
 #include "reftable/reftable-writer.h"
@@ -440,6 +441,8 @@ static void t_default_write_opts(void)
 	check_int(hash_id, ==, GIT_SHA1_FORMAT_ID);
 
 	reftable_table_from_reader(&tab[0], rd);
+	err = reftable_new_merged_table(&merged, tab, 1, GIT_SHA256_FORMAT_ID);
+	check_int(err, ==, REFTABLE_FORMAT_ERROR);
 	err = reftable_new_merged_table(&merged, tab, 1, GIT_SHA1_FORMAT_ID);
 	check(!err);
 
-- 
2.45.2.404.g9eaef5822c
Previous: Chandra PratapNext: Karthik Nayak
Message 20 of 41 in “t: port reftable/merged_test.c to the unit testing framework”
  1. Chandra PratapJul 3, 2024
  2. 1/5 t: move reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 3, 2024
  3. Karthik NayakJul 5, 2024
  4. Chandra PratapJul 6, 2024
  5. 2/5 t: harmonize t-reftable-merged.c with coding guidelinesChandra Pratap, Jul 3, 2024
  6. Karthik NayakJul 5, 2024
  7. 3/5 t-reftable-merged: add tests for reftable_merged_table_max_update_indexChandra Pratap, Jul 3, 2024
  8. 4/5 t-reftable-merged: use reftable_ref_record_equal to compare ref recordsChandra Pratap, Jul 3, 2024
  9. Karthik NayakJul 5, 2024
  10. 5/5 t-reftable-merged: add test for REFTABLE_FORMAT_ERRORChandra Pratap, Jul 3, 2024
  11. Karthik NayakJul 5, 2024
  12. [GSoC][PATCH v2 0/7] t: port reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 9, 2024
  13. 1/7 t: move reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 9, 2024
  14. Justin ToblerJul 9, 2024
  15. 2/7 t: harmonize t-reftable-merged.c with coding guidelinesChandra Pratap, Jul 9, 2024
  16. 3/7 t-reftable-merged: improve the test t_merged_single_record()Chandra Pratap, Jul 9, 2024
  17. 4/7 t-reftable-merged: improve the const-correctness of helper functionsChandra Pratap, Jul 9, 2024
  18. 5/7 t-reftable-merged: add tests for reftable_merged_table_max_update_indexChandra Pratap, Jul 9, 2024
  19. 6/7 t-reftable-merged: use reftable_ref_record_equal to compare ref recordsChandra Pratap, Jul 9, 2024
  20. 7/7 t-reftable-merged: add test for REFTABLE_FORMAT_ERRORChandra Pratap, Jul 9, 2024
  21. Karthik NayakJul 10, 2024
  22. Karthik NayakJul 10, 2024
  23. Junio C HamanoJul 11, 2024
  24. [GSoC][PATCH v3 0/7] t: port reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 11, 2024
  25. 1/7 t: move reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 11, 2024
  26. 2/7 t: harmonize t-reftable-merged.c with coding guidelinesChandra Pratap, Jul 11, 2024
  27. Junio C HamanoJul 11, 2024
  28. 3/7 t-reftable-merged: improve the test t_merged_single_record()Chandra Pratap, Jul 11, 2024
  29. 4/7 t-reftable-merged: improve the const-correctness of helper functionsChandra Pratap, Jul 11, 2024
  30. 5/7 t-reftable-merged: add tests for reftable_merged_table_max_update_indexChandra Pratap, Jul 11, 2024
  31. 6/7 t-reftable-merged: use reftable_ref_record_equal to compare ref recordsChandra Pratap, Jul 11, 2024
  32. 7/7 t-reftable-merged: add test for REFTABLE_FORMAT_ERRORChandra Pratap, Jul 11, 2024
  33. [GSoC][PATCH v4 0/7] t: port reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 12, 2024
  34. 1/7 t: move reftable/merged_test.c to the unit testing frameworkChandra Pratap, Jul 12, 2024
  35. 2/7 t: harmonize t-reftable-merged.c with coding guidelinesChandra Pratap, Jul 12, 2024
  36. 3/7 t-reftable-merged: improve the test t_merged_single_record()Chandra Pratap, Jul 12, 2024
  37. 4/7 t-reftable-merged: improve the const-correctness of helper functionsChandra Pratap, Jul 12, 2024
  38. Patrick SteinhardtJul 24, 2024
  39. 5/7 t-reftable-merged: add tests for reftable_merged_table_max_update_indexChandra Pratap, Jul 12, 2024
  40. 6/7 t-reftable-merged: use reftable_ref_record_equal to compare ref recordsChandra Pratap, Jul 12, 2024
  41. 7/7 t-reftable-merged: add test for REFTABLE_FORMAT_ERRORChandra Pratap, Jul 12, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.