Skip to content

Commit 9a1fb8a

Browse files
Chandra Pratapgitster
authored andcommitted
t-reftable-merged: add test for REFTABLE_FORMAT_ERROR
When calling reftable_new_merged_table(), if the hash ID of the passed 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 <[email protected]> Mentored-by: Christian Couder <[email protected]> Signed-off-by: Chandra Pratap <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 40c80ea commit 9a1fb8a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

t/unit-tests/t-reftable-merged.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ license that can be found in the LICENSE file or at
1111
#include "reftable/constants.h"
1212
#include "reftable/merged.h"
1313
#include "reftable/reader.h"
14+
#include "reftable/reftable-error.h"
1415
#include "reftable/reftable-generic.h"
1516
#include "reftable/reftable-merged.h"
1617
#include "reftable/reftable-writer.h"
@@ -440,6 +441,8 @@ static void t_default_write_opts(void)
440441
check_int(hash_id, ==, GIT_SHA1_FORMAT_ID);
441442

442443
reftable_table_from_reader(&tab[0], rd);
444+
err = reftable_new_merged_table(&merged, tab, 1, GIT_SHA256_FORMAT_ID);
445+
check_int(err, ==, REFTABLE_FORMAT_ERROR);
443446
err = reftable_new_merged_table(&merged, tab, 1, GIT_SHA1_FORMAT_ID);
444447
check(!err);
445448

0 commit comments

Comments
 (0)