Message ID | 20240709053847.4453-8-chandrapratap3519@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | t: port reftable/merged_test.c to the unit testing framework | expand |
Chandra Pratap <chandrapratap3519@gmail.com> writes: > When calling reftable_new_merged_table(), if the hash ID of the > passsed reftable_table parameter doesn't match the passed hash_id s/passsed/passed > 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
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);
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(+)