mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Add timeout to test
This commit is contained in:
parent
79f75b9119
commit
68818758a2
1 changed files with 18 additions and 10 deletions
|
@ -1,18 +1,26 @@
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use librespot_core::authentication::Credentials;
|
use librespot_core::authentication::Credentials;
|
||||||
use librespot_core::config::SessionConfig;
|
use librespot_core::config::SessionConfig;
|
||||||
use librespot_core::session::Session;
|
use librespot_core::session::Session;
|
||||||
|
|
||||||
|
use tokio::time::timeout;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_connection() {
|
async fn test_connection() {
|
||||||
let result = Session::connect(
|
timeout(Duration::from_secs(30), async {
|
||||||
SessionConfig::default(),
|
let result = Session::connect(
|
||||||
Credentials::with_password("test", "test"),
|
SessionConfig::default(),
|
||||||
None,
|
Credentials::with_password("test", "test"),
|
||||||
)
|
None,
|
||||||
.await;
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => panic!("Authentication succeeded despite of bad credentials."),
|
Ok(_) => panic!("Authentication succeeded despite of bad credentials."),
|
||||||
Err(e) => assert_eq!(e.to_string(), "Login failed with reason: Bad credentials"),
|
Err(e) => assert_eq!(e.to_string(), "Login failed with reason: Bad credentials"),
|
||||||
};
|
}
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue