@@ -114,6 +114,7 @@ mod tests {
114114 use assert_matches:: assert_matches;
115115 use axum:: routing:: get;
116116 use axum:: Router ;
117+ use camino:: Utf8PathBuf ;
117118 use std:: io:: Cursor ;
118119
119120 mod read_trust_store {
@@ -199,27 +200,28 @@ mod tests {
199200 }
200201
201202 fn copy_test_file_to ( test_file : & str , path : impl AsRef < Path > ) -> io:: Result < u64 > {
202- std:: fs:: copy ( format ! ( "./test_data/{test_file}" ) , path)
203+ let dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
204+ std:: fs:: copy ( format ! ( "{dir}/test_data/{test_file}" ) , path)
203205 }
204206 }
205207
206208 #[ test]
207209 fn load_pkey_fails_when_given_x509_certificate ( ) {
210+ let dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
211+ let path = Utf8PathBuf :: from ( format ! ( "{dir}/test_data/ec.crt" ) ) ;
208212 assert_eq ! (
209- load_pkey( Utf8Path :: new( "./test_data/ec.crt" ) )
210- . unwrap_err( )
211- . to_string( ) ,
212- "expected private key in \" ./test_data/ec.crt\" , found an X509 certificate"
213+ load_pkey( & path) . unwrap_err( ) . to_string( ) ,
214+ format!( "expected private key in {path:?}, found an X509 certificate" )
213215 ) ;
214216 }
215217
216218 #[ test]
217219 fn load_pkey_fails_when_given_certificate_revocation_list ( ) {
220+ let dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
221+ let path = Utf8PathBuf :: from ( format ! ( "{dir}/test_data/demo.crl" ) ) ;
218222 assert_eq ! (
219- load_pkey( Utf8Path :: new( "./test_data/demo.crl" ) )
220- . unwrap_err( )
221- . to_string( ) ,
222- "expected private key in \" ./test_data/demo.crl\" , found a CRL"
223+ load_pkey( & path) . unwrap_err( ) . to_string( ) ,
224+ format!( "expected private key in {path:?}, found a CRL" )
223225 ) ;
224226 }
225227
@@ -288,7 +290,8 @@ mod tests {
288290 }
289291
290292 fn test_data ( file_name : & str ) -> String {
291- std:: fs:: read_to_string ( format ! ( "./test_data/{file_name}" ) )
293+ let dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
294+ std:: fs:: read_to_string ( format ! ( "{dir}/test_data/{file_name}" ) )
292295 . with_context ( || format ! ( "opening file {file_name} from test_data" ) )
293296 . unwrap ( )
294297 }
0 commit comments