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