@@ -41,7 +41,7 @@ fn uuid_to_sql() {
4141 let test_uuid = uuid:: Uuid :: from_slice ( & bytes) . unwrap ( ) ;
4242 let mut bytes = Output :: test ( ByteWrapper ( & mut buffer) ) ;
4343 ToSql :: < Uuid , Pg > :: to_sql ( & test_uuid, & mut bytes) . unwrap ( ) ;
44- assert_eq ! ( buffer, test_uuid. into_bytes ( ) ) ;
44+ assert_eq ! ( & buffer, test_uuid. as_bytes ( ) ) ;
4545}
4646
4747#[ test]
@@ -59,10 +59,18 @@ fn some_uuid_from_sql() {
5959#[ test]
6060fn bad_uuid_from_sql ( ) {
6161 let uuid = uuid:: Uuid :: from_sql ( PgValue :: for_test ( b"boom" ) ) ;
62- assert_eq ! (
63- uuid. unwrap_err( ) . to_string( ) ,
64- "invalid length: expected 16 bytes, found 4"
65- ) ;
62+ assert ! ( uuid. is_err( ) ) ;
63+ // The error message changes slightly between different
64+ // uuid versions, so we just check on the relevant parts
65+ // The exact error messages are either:
66+ // "invalid bytes length: expected 16, found 4"
67+ // or
68+ // "invalid length: expected 16 bytes, found 4"
69+ let error_message = uuid. unwrap_err ( ) . to_string ( ) ;
70+ assert ! ( error_message. starts_with( "invalid" ) ) ;
71+ assert ! ( error_message. contains( "length" ) ) ;
72+ assert ! ( error_message. contains( "expected 16" ) ) ;
73+ assert ! ( error_message. ends_with( "found 4" ) ) ;
6674}
6775
6876#[ test]
0 commit comments