Message ID | 20240904150132.11567-5-chandrapratap3519@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | t: port reftable/stack_test.c to the unit testing framework | expand |
On Wed, Sep 04, 2024 at 08:08:04PM +0530, Chandra Pratap wrote: > In the current stack tests, ref records are compared for equality > by sometimes using the dedicated function for ref-record comparison, > reftable_ref_record_equal(), and sometimes by explicity comparing > contents of the ref records. > > Replace the latter instances of ref-record comparison with the > former to maintain uniformity throughout the test file. It's not really about uniformity in my opinion. It's rather that the function is a lot more thorough than only comparing the refname, which I think is the real win here. Patrick > 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-stack.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/t/unit-tests/t-reftable-stack.c b/t/unit-tests/t-reftable-stack.c > index 8047e25c48..4f2ef1a8cc 100644 > --- a/t/unit-tests/t-reftable-stack.c > +++ b/t/unit-tests/t-reftable-stack.c > @@ -174,7 +174,7 @@ static void t_reftable_stack_add_one(void) > > err = reftable_stack_read_ref(st, ref.refname, &dest); > check(!err); > - check_str("master", dest.value.symref); > + check(reftable_ref_record_equal(&ref, &dest, GIT_SHA1_RAWSZ)); > check_int(st->readers_len, >, 0); > > #ifndef GIT_WINDOWS_NATIVE > @@ -285,7 +285,7 @@ static void t_reftable_stack_transaction_api(void) > err = reftable_stack_read_ref(st, ref.refname, &dest); > check(!err); > check_int(REFTABLE_REF_SYMREF, ==, dest.value_type); > - check_str("master", dest.value.symref); > + check(reftable_ref_record_equal(&ref, &dest, GIT_SHA1_RAWSZ)); > > reftable_ref_record_release(&dest); > reftable_stack_destroy(st); > -- > 2.45.GIT >
diff --git a/t/unit-tests/t-reftable-stack.c b/t/unit-tests/t-reftable-stack.c index 8047e25c48..4f2ef1a8cc 100644 --- a/t/unit-tests/t-reftable-stack.c +++ b/t/unit-tests/t-reftable-stack.c @@ -174,7 +174,7 @@ static void t_reftable_stack_add_one(void) err = reftable_stack_read_ref(st, ref.refname, &dest); check(!err); - check_str("master", dest.value.symref); + check(reftable_ref_record_equal(&ref, &dest, GIT_SHA1_RAWSZ)); check_int(st->readers_len, >, 0); #ifndef GIT_WINDOWS_NATIVE @@ -285,7 +285,7 @@ static void t_reftable_stack_transaction_api(void) err = reftable_stack_read_ref(st, ref.refname, &dest); check(!err); check_int(REFTABLE_REF_SYMREF, ==, dest.value_type); - check_str("master", dest.value.symref); + check(reftable_ref_record_equal(&ref, &dest, GIT_SHA1_RAWSZ)); reftable_ref_record_release(&dest); reftable_stack_destroy(st);
In the current stack tests, ref records are compared for equality by sometimes using the dedicated function for ref-record comparison, reftable_ref_record_equal(), and sometimes by explicity comparing contents of the ref records. Replace the latter instances of ref-record comparison with the former to maintain uniformity throughout the test file. 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-stack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)