diff mbox series

[4/5] t-reftable-merged: use reftable_ref_record_equal to compare ref records

Message ID 20240703171131.3929-5-chandrapratap3519@gmail.com (mailing list archive)
State Superseded
Headers show
Series t: port reftable/merged_test.c to the unit testing framework | expand

Commit Message

Chandra Pratap July 3, 2024, 5:01 p.m. UTC
In the test test_merged_between() defined in t-reftable-merged.c,
the 'input' and 'expected' ref records are checked for equality
by comparing their update indices. It is very much possible for
two different ref records to have the same update indices. Use
reftable_ref_record_equal() as well for a stronger check.

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 | 1 +
 1 file changed, 1 insertion(+)

Comments

karthik nayak July 5, 2024, 6:14 p.m. UTC | #1
Chandra Pratap <chandrapratap3519@gmail.com> writes:

> In the test test_merged_between() defined in t-reftable-merged.c,
>

s/test_merged_between/t_merged_between

> the 'input' and 'expected' ref records are checked for equality
> by comparing their update indices. It is very much possible for
> two different ref records to have the same update indices. Use
> reftable_ref_record_equal() as well for a stronger check.
>
> 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 | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/t/unit-tests/t-reftable-merged.c b/t/unit-tests/t-reftable-merged.c
> index 543113f3d4..656193550d 100644
> --- a/t/unit-tests/t-reftable-merged.c
> +++ b/t/unit-tests/t-reftable-merged.c
> @@ -155,6 +155,7 @@ static void t_merged_between(void)
>  	err = reftable_iterator_next_ref(&it, &ref);
>  	check(!err);
>  	check_int(ref.update_index, ==, 2);
> +	check(reftable_ref_record_equal(&r2[0], &ref, GIT_SHA1_RAWSZ));

We can actually remove `check_int(ref.update_index, ==, 2)` since the
new check also would compare the update_index.

>  	reftable_ref_record_release(&ref);
>  	reftable_iterator_destroy(&it);
>  	readers_destroy(readers, 2);
> --
> 2.45.2.404.g9eaef5822c
diff mbox series

Patch

diff --git a/t/unit-tests/t-reftable-merged.c b/t/unit-tests/t-reftable-merged.c
index 543113f3d4..656193550d 100644
--- a/t/unit-tests/t-reftable-merged.c
+++ b/t/unit-tests/t-reftable-merged.c
@@ -155,6 +155,7 @@  static void t_merged_between(void)
 	err = reftable_iterator_next_ref(&it, &ref);
 	check(!err);
 	check_int(ref.update_index, ==, 2);
+	check(reftable_ref_record_equal(&r2[0], &ref, GIT_SHA1_RAWSZ));
 	reftable_ref_record_release(&ref);
 	reftable_iterator_destroy(&it);
 	readers_destroy(readers, 2);