@@ -90,7 +90,7 @@ static void t_log_buffer_size(void)
90
90
int i ;
91
91
struct reftable_log_record
92
92
log = { .refname = (char * ) "refs/heads/master" ,
93
- .update_index = 0xa ,
93
+ .update_index = update_index ,
94
94
.value_type = REFTABLE_LOG_UPDATE ,
95
95
.value = { .update = {
96
96
.name = (char * ) "Han-Wen Nienhuys" ,
@@ -127,7 +127,7 @@ static void t_log_overflow(void)
127
127
int err ;
128
128
struct reftable_log_record log = {
129
129
.refname = (char * ) "refs/heads/master" ,
130
- .update_index = 0xa ,
130
+ .update_index = update_index ,
131
131
.value_type = REFTABLE_LOG_UPDATE ,
132
132
.value = {
133
133
.update = {
@@ -151,6 +151,48 @@ static void t_log_overflow(void)
151
151
reftable_buf_release (& buf );
152
152
}
153
153
154
+ static void t_log_write_limits (void )
155
+ {
156
+ struct reftable_write_options opts = { 0 };
157
+ struct reftable_buf buf = REFTABLE_BUF_INIT ;
158
+ struct reftable_writer * w = t_reftable_strbuf_writer (& buf , & opts );
159
+ struct reftable_log_record log = {
160
+ .refname = (char * )"refs/head/master" ,
161
+ .update_index = 0 ,
162
+ .value_type = REFTABLE_LOG_UPDATE ,
163
+ .value = {
164
+ .update = {
165
+ .old_hash = { 1 },
166
+ .new_hash = { 2 },
167
+ .name = (char * )"Han-Wen Nienhuys" ,
168
+ .
email = (
char * )
"[email protected] " ,
169
+ .tz_offset = 100 ,
170
+ .time = 0x5e430672 ,
171
+ },
172
+ },
173
+ };
174
+ int err ;
175
+
176
+ reftable_writer_set_limits (w , 1 , 1 );
177
+
178
+ /* write with update_index (0) below set limits (1, 1) */
179
+ err = reftable_writer_add_log (w , & log );
180
+ check_int (err , = = , 0 );
181
+
182
+ /* write with update_index (1) in the set limits (1, 1) */
183
+ log .update_index = 1 ;
184
+ err = reftable_writer_add_log (w , & log );
185
+ check_int (err , = = , 0 );
186
+
187
+ /* write with update_index (3) above set limits (1, 1) */
188
+ log .update_index = 3 ;
189
+ err = reftable_writer_add_log (w , & log );
190
+ check_int (err , = = , REFTABLE_API_ERROR );
191
+
192
+ reftable_writer_free (w );
193
+ reftable_buf_release (& buf );
194
+ }
195
+
154
196
static void t_log_write_read (void )
155
197
{
156
198
struct reftable_write_options opts = {
@@ -917,6 +959,7 @@ int cmd_main(int argc UNUSED, const char *argv[] UNUSED)
917
959
TEST (t_corrupt_table_empty (), "read-write on an empty table" );
918
960
TEST (t_log_buffer_size (), "buffer extension for log compression" );
919
961
TEST (t_log_overflow (), "log overflow returns expected error" );
962
+ TEST (t_log_write_limits (), "writer limits for writing log records" );
920
963
TEST (t_log_write_read (), "read-write on log records" );
921
964
TEST (t_log_zlib_corruption (), "reading corrupted log record returns expected error" );
922
965
TEST (t_table_read_api (), "read on a table" );
0 commit comments