mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +00:00
Added test
This commit is contained in:
parent
40e6355c34
commit
6867ad0750
1 changed files with 32 additions and 0 deletions
32
core/tests/connect.rs
Normal file
32
core/tests/connect.rs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
use librespot_core::*;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
// Test AP Resolve
|
||||||
|
use apresolve::apresolve_or_fallback;
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_ap_resolve() {
|
||||||
|
let ap = apresolve_or_fallback(&None, &None).await;
|
||||||
|
println!("AP: {:?}", ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test connect
|
||||||
|
use authentication::Credentials;
|
||||||
|
use config::SessionConfig;
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_connection() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
println!("Running connection test");
|
||||||
|
let ap = apresolve_or_fallback(&None, &None).await;
|
||||||
|
let credentials = Credentials::with_password(String::from("test"), String::from("test"));
|
||||||
|
let session_config = SessionConfig::default();
|
||||||
|
let proxy = None;
|
||||||
|
|
||||||
|
println!("Connecting to AP \"{}\"", ap);
|
||||||
|
let mut connection = connection::connect(ap, &proxy).await?;
|
||||||
|
let rc = connection::authenticate(&mut connection, credentials, &session_config.device_id)
|
||||||
|
.await?;
|
||||||
|
println!("Authenticated as \"{}\"", rc.username);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue