Fix errors caused by sync locks crossing `await` in `cli::authenticate`
This commit is contained in:
		
							parent
							
								
									9084c1fcaa
								
							
						
					
					
						commit
						2301fda307
					
				|  | @ -7,6 +7,7 @@ use crate::{errors::Result, registration::Registered, Mastodon}; | ||||||
| pub async fn authenticate(registration: Registered) -> Result<Mastodon> { | pub async fn authenticate(registration: Registered) -> Result<Mastodon> { | ||||||
|     let url = registration.authorize_url()?; |     let url = registration.authorize_url()?; | ||||||
| 
 | 
 | ||||||
|  |     let code = { | ||||||
|         let stdout = io::stdout(); |         let stdout = io::stdout(); | ||||||
|         let stdin = io::stdin(); |         let stdin = io::stdin(); | ||||||
| 
 | 
 | ||||||
|  | @ -19,6 +20,25 @@ pub async fn authenticate(registration: Registered) -> Result<Mastodon> { | ||||||
| 
 | 
 | ||||||
|         let mut input = String::new(); |         let mut input = String::new(); | ||||||
|         stdin.read_line(&mut input)?; |         stdin.read_line(&mut input)?; | ||||||
|     let code = input.trim(); |         input | ||||||
|  |     }; | ||||||
|  |     let code = code.trim(); | ||||||
|  | 
 | ||||||
|     registration.complete(code).await |     registration.complete(code).await | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | #[cfg(test)] | ||||||
|  | mod tests { | ||||||
|  |     use super::*; | ||||||
|  | 
 | ||||||
|  |     #[test] | ||||||
|  |     fn send_sync() { | ||||||
|  |         fn assert_send_sync(_: impl Send + Sync) {} | ||||||
|  | 
 | ||||||
|  |         let mock_reg = || -> Registered { unimplemented!() }; | ||||||
|  |         let no_run = || async move { | ||||||
|  |             let _ = authenticate(mock_reg()).await; | ||||||
|  |         }; | ||||||
|  |         assert_send_sync(no_run()); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue