Skip to content

Commit 6881875

Browse files
committed
Add timeout to test
1 parent 79f75b9 commit 6881875

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

core/tests/connect.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1+
use std::time::Duration;
2+
13
use librespot_core::authentication::Credentials;
24
use librespot_core::config::SessionConfig;
35
use librespot_core::session::Session;
46

7+
use tokio::time::timeout;
8+
59
#[tokio::test]
610
async fn test_connection() {
7-
let result = Session::connect(
8-
SessionConfig::default(),
9-
Credentials::with_password("test", "test"),
10-
None,
11-
)
12-
.await;
11+
timeout(Duration::from_secs(30), async {
12+
let result = Session::connect(
13+
SessionConfig::default(),
14+
Credentials::with_password("test", "test"),
15+
None,
16+
)
17+
.await;
1318

14-
match result {
15-
Ok(_) => panic!("Authentication succeeded despite of bad credentials."),
16-
Err(e) => assert_eq!(e.to_string(), "Login failed with reason: Bad credentials"),
17-
};
19+
match result {
20+
Ok(_) => panic!("Authentication succeeded despite of bad credentials."),
21+
Err(e) => assert_eq!(e.to_string(), "Login failed with reason: Bad credentials"),
22+
}
23+
})
24+
.await
25+
.unwrap();
1826
}

0 commit comments

Comments
 (0)