@@ -262,7 +262,7 @@ mod write_object {
262
262
let oid = repo. write_object ( gix:: objs:: TreeRef :: empty ( ) ) ?;
263
263
assert_eq ! (
264
264
oid,
265
- gix :: hash :: ObjectId :: empty_tree ( repo. object_hash( ) ) ,
265
+ repo. object_hash( ) . empty_tree ( ) ,
266
266
"it produces a well-known empty tree id"
267
267
) ;
268
268
Ok ( ( ) )
@@ -277,7 +277,7 @@ mod write_object {
277
277
time : Default :: default ( ) ,
278
278
} ;
279
279
let commit = gix:: objs:: Commit {
280
- tree : gix :: hash :: ObjectId :: empty_tree ( repo. object_hash ( ) ) ,
280
+ tree : repo. object_hash ( ) . empty_tree ( ) ,
281
281
author : actor. clone ( ) ,
282
282
committer : actor,
283
283
parents : Default :: default ( ) ,
@@ -296,74 +296,15 @@ mod write_object {
296
296
#[ test]
297
297
fn blob_write_to_implementation ( ) -> crate :: Result {
298
298
let repo = empty_bare_in_memory_repo ( ) ?;
299
- let test_data = b"hello world" ;
300
-
299
+ let blob = repo . empty_blob ( ) ;
300
+
301
301
// Create a blob directly to test our WriteTo implementation
302
- let blob_id = repo. write_blob ( test_data) ?;
303
- let blob = repo. find_object ( blob_id) ?. into_blob ( ) ;
304
-
305
- // Test that we can use the blob with write_object (which requires WriteTo)
306
- let written_id = repo. write_object ( blob) ?;
307
-
308
- // The written blob should have the same ID as the original
309
- assert_eq ! ( blob_id, written_id, "WriteTo implementation should produce identical blob" ) ;
310
-
311
- // Verify the content is correct
312
- let retrieved_blob = repo. find_object ( written_id) ?. into_blob ( ) ;
313
- assert_eq ! ( retrieved_blob. data, test_data, "Blob data should be preserved" ) ;
314
-
315
- Ok ( ( ) )
316
- }
302
+ let actual_id = repo. write_object ( & blob) ?;
303
+ let actual_blob = repo. find_object ( actual_id) ?. into_blob ( ) ;
304
+ assert_eq ! ( actual_id, repo. object_hash( ) . empty_blob( ) ) ;
317
305
318
- #[ test]
319
- fn blob_write_to_properties ( ) -> crate :: Result {
320
- let repo = empty_bare_in_memory_repo ( ) ?;
321
- let test_data = b"test data for WriteTo properties" ;
322
-
323
- // Create a blob to test WriteTo trait methods
324
- let blob_id = repo. write_blob ( test_data) ?;
325
- let blob = repo. find_object ( blob_id) ?. into_blob ( ) ;
326
-
327
- // Test WriteTo trait methods directly
328
- use gix_object:: WriteTo ;
329
-
330
- // Test kind() method
331
- assert_eq ! ( blob. kind( ) , gix_object:: Kind :: Blob , "kind() should return Blob" ) ;
332
-
333
- // Test size() method
334
- assert_eq ! ( blob. size( ) , test_data. len( ) as u64 , "size() should return data length" ) ;
335
-
336
- // Test write_to() method
337
- let mut buffer = Vec :: new ( ) ;
338
- blob. write_to ( & mut buffer) ?;
339
- assert_eq ! ( buffer, test_data, "write_to() should write blob data verbatim" ) ;
340
-
341
- Ok ( ( ) )
342
- }
306
+ assert_eq ! ( actual_blob. data, blob. data) ;
343
307
344
- #[ test]
345
- fn blob_write_to_empty_blob ( ) -> crate :: Result {
346
- let repo = empty_bare_in_memory_repo ( ) ?;
347
- let empty_data = b"" ;
348
-
349
- // Create an empty blob to test edge case
350
- let blob_id = repo. write_blob ( empty_data) ?;
351
- let blob = repo. find_object ( blob_id) ?. into_blob ( ) ;
352
-
353
- // Test WriteTo trait methods with empty blob
354
- use gix_object:: WriteTo ;
355
-
356
- assert_eq ! ( blob. kind( ) , gix_object:: Kind :: Blob , "kind() should return Blob for empty blob" ) ;
357
- assert_eq ! ( blob. size( ) , 0 , "size() should return 0 for empty blob" ) ;
358
-
359
- let mut buffer = Vec :: new ( ) ;
360
- blob. write_to ( & mut buffer) ?;
361
- assert_eq ! ( buffer, empty_data, "write_to() should write empty data for empty blob" ) ;
362
-
363
- // Test that we can write the empty blob using write_object
364
- let written_id = repo. write_object ( blob) ?;
365
- assert_eq ! ( blob_id, written_id, "WriteTo implementation should work for empty blobs" ) ;
366
-
367
308
Ok ( ( ) )
368
309
}
369
310
}
0 commit comments