@@ -384,6 +384,22 @@ mod tests {
384
384
. insert_file ( expected_file. path . clone ( ) )
385
385
. unwrap ( ) ;
386
386
assert_eq ! ( actual_file, expected_file) ;
387
+
388
+ let duplicate_result = report_builder. insert_file ( expected_file. path . clone ( ) ) ;
389
+ match duplicate_result {
390
+ Err ( CodecovError :: SqliteError ( rusqlite:: Error :: SqliteFailure (
391
+ rusqlite:: ffi:: Error {
392
+ code : rusqlite:: ffi:: ErrorCode :: ConstraintViolation ,
393
+ extended_code : 1555 ,
394
+ } ,
395
+ Some ( s) ,
396
+ ) ) ) => {
397
+ assert_eq ! ( s, String :: from( "UNIQUE constraint failed: source_file.id" ) ) ;
398
+ }
399
+ _ => {
400
+ assert ! ( false ) ;
401
+ }
402
+ }
387
403
}
388
404
389
405
#[ test]
@@ -401,6 +417,23 @@ mod tests {
401
417
. insert_context ( expected_context. context_type , & expected_context. name )
402
418
. unwrap ( ) ;
403
419
assert_eq ! ( actual_context, expected_context) ;
420
+
421
+ let duplicate_result =
422
+ report_builder. insert_context ( expected_context. context_type , & expected_context. name ) ;
423
+ match duplicate_result {
424
+ Err ( CodecovError :: SqliteError ( rusqlite:: Error :: SqliteFailure (
425
+ rusqlite:: ffi:: Error {
426
+ code : rusqlite:: ffi:: ErrorCode :: ConstraintViolation ,
427
+ extended_code : 1555 ,
428
+ } ,
429
+ Some ( s) ,
430
+ ) ) ) => {
431
+ assert_eq ! ( s, String :: from( "UNIQUE constraint failed: context.id" ) ) ;
432
+ }
433
+ _ => {
434
+ assert ! ( false ) ;
435
+ }
436
+ }
404
437
}
405
438
406
439
#[ test]
@@ -623,6 +656,27 @@ mod tests {
623
656
} )
624
657
. unwrap ( ) ;
625
658
assert_eq ! ( actual_assoc, expected_assoc) ;
659
+
660
+ let duplicate_result = report_builder. associate_context ( expected_assoc. clone ( ) ) ;
661
+ match duplicate_result {
662
+ Err ( CodecovError :: SqliteError ( rusqlite:: Error :: SqliteFailure (
663
+ rusqlite:: ffi:: Error {
664
+ code : rusqlite:: ffi:: ErrorCode :: ConstraintViolation ,
665
+ extended_code : 1555 ,
666
+ } ,
667
+ Some ( s) ,
668
+ ) ) ) => {
669
+ assert_eq ! (
670
+ s,
671
+ String :: from(
672
+ "UNIQUE constraint failed: context_assoc.context_id, context_assoc.sample_id"
673
+ )
674
+ ) ;
675
+ }
676
+ _ => {
677
+ assert ! ( false ) ;
678
+ }
679
+ }
626
680
}
627
681
628
682
#[ test]
0 commit comments