diff options
Diffstat (limited to 'tests/scrobbler.rs')
| -rw-r--r-- | tests/scrobbler.rs | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/tests/scrobbler.rs b/tests/scrobbler.rs index f326250..5453748 100644 --- a/tests/scrobbler.rs +++ b/tests/scrobbler.rs | |||
| @@ -24,54 +24,52 @@ fn test_scrobbler_new_with_none() { | |||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | #[test] | 26 | #[test] |
| 27 | fn test_scrobbler_now_playing_no_api_key() { | 27 | fn test_scrobbler_now_playing_no_creds() { |
| 28 | let scrobbler = Scrobbler::new(None, None, None, None); | 28 | let scrobbler = Scrobbler::new(None, None, None, None); |
| 29 | scrobbler.now_playing("Artist", "Track", Some("Album")); | 29 | scrobbler.now_playing("Artist", "Track", Some("Album")); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | #[test] | 32 | #[test] |
| 33 | fn test_scrobbler_now_playing_with_api_key() { | 33 | fn test_scrobbler_now_playing_partial_lastfm() { |
| 34 | // Only api_key set — not enough to trigger Last.fm (needs secret + session_key too) | ||
| 34 | let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); | 35 | let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); |
| 35 | scrobbler.now_playing("Artist", "Track", Some("Album")); | 36 | scrobbler.now_playing("Artist", "Track", Some("Album")); |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | #[test] | 39 | #[test] |
| 39 | fn test_scrobbler_scrobble_no_keys() { | 40 | fn test_scrobbler_now_playing_no_album() { |
| 40 | let scrobbler = Scrobbler::new(None, None, None, None); | ||
| 41 | scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); | ||
| 42 | } | ||
| 43 | |||
| 44 | #[test] | ||
| 45 | fn test_scrobbler_scrobble_with_lastfm() { | ||
| 46 | let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); | 41 | let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); |
| 47 | scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); | 42 | scrobbler.now_playing("Artist", "Track", None); |
| 48 | } | 43 | } |
| 49 | 44 | ||
| 50 | #[test] | 45 | #[test] |
| 51 | fn test_scrobbler_scrobble_with_listenbrainz() { | 46 | fn test_scrobbler_scrobble_no_creds() { |
| 52 | let scrobbler = Scrobbler::new(None, None, None, Some("token".to_string())); | 47 | let scrobbler = Scrobbler::new(None, None, None, None); |
| 53 | scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); | 48 | scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); |
| 54 | } | 49 | } |
| 55 | 50 | ||
| 56 | #[test] | 51 | #[test] |
| 57 | fn test_scrobbler_scrobble_with_both() { | 52 | fn test_scrobbler_scrobble_no_album() { |
| 58 | let scrobbler = Scrobbler::new( | 53 | let scrobbler = Scrobbler::new(None, None, None, None); |
| 59 | Some("api_key".to_string()), | 54 | scrobbler.scrobble("Artist", "Track", None, 1234567890); |
| 60 | None, | ||
| 61 | None, | ||
| 62 | Some("token".to_string()), | ||
| 63 | ); | ||
| 64 | scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); | ||
| 65 | } | 55 | } |
| 66 | 56 | ||
| 67 | #[test] | 57 | #[test] |
| 68 | fn test_scrobbler_now_playing_no_album() { | 58 | fn test_scrobbler_scrobble_partial_lastfm() { |
| 59 | // Only api_key set — not enough to trigger Last.fm | ||
| 69 | let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); | 60 | let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); |
| 70 | scrobbler.now_playing("Artist", "Track", None); | 61 | scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); |
| 71 | } | 62 | } |
| 72 | 63 | ||
| 73 | #[test] | 64 | #[test] |
| 74 | fn test_scrobbler_scrobble_no_album() { | 65 | fn test_scrobbler_skip_empty_credentials() { |
| 75 | let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); | 66 | // Empty strings should be treated as unset — no HTTP requests |
| 76 | scrobbler.scrobble("Artist", "Track", None, 1234567890); | 67 | let scrobbler = Scrobbler::new( |
| 68 | Some("".to_string()), | ||
| 69 | Some("".to_string()), | ||
| 70 | Some("".to_string()), | ||
| 71 | Some("".to_string()), | ||
| 72 | ); | ||
| 73 | scrobbler.now_playing("Artist", "Track", Some("Album")); | ||
| 74 | scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); | ||
| 77 | } | 75 | } |
