| 797 | } |
| 798 | |
| 799 | void test_reftable_stack__hash_id(void) |
| 800 | { |
| 801 | char *dir = get_tmp_dir(__LINE__); |
| 802 | struct reftable_write_options opts = { 0 }; |
| 803 | struct reftable_stack *st = NULL; |
| 804 | |
| 805 | struct reftable_ref_record ref = { |
| 806 | .refname = (char *) "master", |
| 807 | .value_type = REFTABLE_REF_SYMREF, |
| 808 | .value.symref = (char *) "target", |
| 809 | .update_index = 1, |
| 810 | }; |
| 811 | struct reftable_write_options opts32 = { .hash_id = REFTABLE_HASH_SHA256 }; |
| 812 | struct reftable_stack *st32 = NULL; |
| 813 | struct reftable_write_options opts_default = { 0 }; |
| 814 | struct reftable_stack *st_default = NULL; |
| 815 | struct reftable_ref_record dest = { 0 }; |
| 816 | |
| 817 | cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0); |
| 818 | cl_assert_equal_i(reftable_stack_add(st, write_test_ref, |
| 819 | &ref, 0), 0); |
| 820 | |
| 821 | /* can't read it with the wrong hash ID. */ |
| 822 | cl_assert_equal_i(reftable_new_stack(&st32, dir, |
| 823 | &opts32), REFTABLE_FORMAT_ERROR); |
| 824 | |
| 825 | /* check that we can read it back with default opts too. */ |
| 826 | cl_assert_equal_i(reftable_new_stack(&st_default, dir, |
| 827 | &opts_default), 0); |
| 828 | cl_assert_equal_i(reftable_stack_read_ref(st_default, "master", |
| 829 | &dest), 0); |
| 830 | cl_assert(reftable_ref_record_equal(&ref, &dest, |
| 831 | REFTABLE_HASH_SIZE_SHA1) != 0); |
| 832 | reftable_ref_record_release(&dest); |
| 833 | reftable_stack_destroy(st); |
| 834 | reftable_stack_destroy(st_default); |
| 835 | clear_dir(dir); |
| 836 | } |
| 837 | |
| 838 | void test_reftable_stack__suggest_compaction_segment(void) |
| 839 | { |
nothing calls this directly
no test coverage detected