From aedbe6537b90be9956ee23081b096c6ea283d592 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Wed, 3 Jun 2020 21:30:15 -0700 Subject: [PATCH] Make tests narrower. Evidently the behavior on different platforms is different with regards to whether the final element in a list gets a comma or not, so we can't do a fully-string comparison of the debug output. --- openssl/src/x509/tests.rs | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/openssl/src/x509/tests.rs b/openssl/src/x509/tests.rs index 3e3650b9..74b6aff0 100644 --- a/openssl/src/x509/tests.rs +++ b/openssl/src/x509/tests.rs @@ -36,27 +36,12 @@ fn test_debug() { let cert = include_bytes!("../../test/cert.pem"); let cert = X509::from_pem(cert).unwrap(); let debugged = format!("{:#?}", cert); - let expected = r#"X509 { - serial_number: "8771F7BDEE982FA5", - signature_algorithm: sha256WithRSAEncryption, - issuer: [ - countryName = "AU", - stateOrProvinceName = "Some-State", - organizationName = "Internet Widgits Pty Ltd", - ], - subject: [ - countryName = "AU", - stateOrProvinceName = "Some-State", - organizationName = "Internet Widgits Pty Ltd", - commonName = "foobar.com", - ], - not_before: Aug 14 17:00:03 2016 GMT, - not_after: Aug 12 17:00:03 2026 GMT, - public_key: PKey { - algorithm: "RSA", - }, -}"#; - assert_eq!(expected, debugged); + assert!(debugged.contains(r#"serial_number: "8771F7BDEE982FA5""#)); + assert!(debugged.contains(r#"signature_algorithm: sha256WithRSAEncryption"#)); + assert!(debugged.contains(r#"countryName = "AU""#)); + assert!(debugged.contains(r#"stateOrProvinceName = Some-State"#)); + assert!(debugged.contains(r#"not_before: Aug 14 17:00:03 2016 GMT"#)); + assert!(debugged.contains(r#"not_after: Aug 12 17:00:03 2026 GMT"#)); } #[test]