From 9f57293607a75d0b645b7d45506c7e386ea4b3e6 Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Tue, 21 Sep 2021 23:21:05 +0200 Subject: [PATCH] add atest to make sure eventemitter is not preventing the account from being removed on windows. --- src/accounts.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/accounts.rs b/src/accounts.rs index 65e5b0f3e..105c4b998 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -722,4 +722,28 @@ mod tests { Ok(()) } + + #[async_std::test] + async fn test_account_new_add_remove_with_active_event_emmitter() { + let dir = tempfile::tempdir().unwrap(); + let p: PathBuf = dir.path().join("accounts").into(); + + let mut accounts = Accounts::new("my_os".into(), p.clone()).await.unwrap(); + assert_eq!(accounts.accounts.len(), 0); + assert_eq!(accounts.config.get_selected_account().await, 0); + + accounts.add_account().await.unwrap(); + accounts.add_account().await.unwrap(); + + // Create event emitter. + let mut event_emitter = accounts.get_event_emitter().await; + + // make sure that account is still removed on windows + accounts.remove_account(1).await.unwrap(); + assert_eq!(accounts.config.get_selected_account().await, 2); + assert_eq!(accounts.accounts.len(), 1); + + // make sure event emitter is not dropped before the test + println!("{:?}", event_emitter.recv().await); + } }