added tests, use specific CI
This commit is contained in:
@@ -127,3 +127,72 @@ pub struct RemoteSessionStatus {
|
||||
pub is_playing: bool,
|
||||
pub now_playing_item: Option<crate::jellyfin::NowPlayingItem>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_playback_mode_serialization() {
|
||||
// Test Local playback mode
|
||||
let local_mode = PlaybackMode::Local;
|
||||
let json = serde_json::to_string(&local_mode);
|
||||
assert!(json.is_ok());
|
||||
|
||||
// Test Remote playback mode
|
||||
let remote_mode = PlaybackMode::Remote {
|
||||
session_id: "session-123".to_string(),
|
||||
};
|
||||
let json = serde_json::to_string(&remote_mode);
|
||||
assert!(json.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remote_session_status_serialization() {
|
||||
let status = RemoteSessionStatus {
|
||||
position: 123.45,
|
||||
duration: Some(600.0),
|
||||
is_playing: true,
|
||||
now_playing_item: None,
|
||||
};
|
||||
|
||||
// Should serialize successfully
|
||||
let json = serde_json::to_string(&status);
|
||||
assert!(json.is_ok());
|
||||
|
||||
let serialized = json.unwrap();
|
||||
assert!(serialized.contains("123.45"));
|
||||
assert!(serialized.contains("600"));
|
||||
assert!(serialized.contains("true"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remote_session_status_with_no_duration() {
|
||||
let status = RemoteSessionStatus {
|
||||
position: 0.0,
|
||||
duration: None,
|
||||
is_playing: false,
|
||||
now_playing_item: None,
|
||||
};
|
||||
|
||||
let json = serde_json::to_string(&status).unwrap();
|
||||
assert!(json.contains("null") || json.contains("\"duration\":null"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remote_session_status_various_positions() {
|
||||
let positions = vec![0.0, 30.5, 100.0, 3600.0];
|
||||
|
||||
for pos in positions {
|
||||
let status = RemoteSessionStatus {
|
||||
position: pos,
|
||||
duration: Some(7200.0),
|
||||
is_playing: true,
|
||||
now_playing_item: None,
|
||||
};
|
||||
|
||||
let json = serde_json::to_string(&status).unwrap();
|
||||
assert!(json.contains(&pos.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user