diff options
| author | salmonik <raisersoft@proton.me> | 2026-05-05 23:29:39 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-05-05 23:29:39 +0200 |
| commit | 5f2d1897b245fbee12d17b5910eaf5233ca6802b (patch) | |
| tree | 551b8855ade2f31e0f24539504b0f9b66cdba75f /tests/scrobbler.rs | |
| parent | Add dev/release config separation and volume query command (diff) | |
| download | rsplayer-5f2d1897b245fbee12d17b5910eaf5233ca6802b.tar.gz rsplayer-5f2d1897b245fbee12d17b5910eaf5233ca6802b.zip | |
Add unit tests in /tests directory for config, database, playback, and scrobbler modules
Diffstat (limited to 'tests/scrobbler.rs')
| -rw-r--r-- | tests/scrobbler.rs | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/scrobbler.rs b/tests/scrobbler.rs new file mode 100644 index 0000000..f326250 --- /dev/null +++ b/tests/scrobbler.rs | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | use rsp::scrobbler::Scrobbler; | ||
| 2 | |||
| 3 | #[test] | ||
| 4 | fn test_scrobbler_new_with_all_params() { | ||
| 5 | let scrobbler = Scrobbler::new( | ||
| 6 | Some("api_key".to_string()), | ||
| 7 | Some("secret".to_string()), | ||
| 8 | Some("session".to_string()), | ||
| 9 | Some("token".to_string()), | ||
| 10 | ); | ||
| 11 | assert!(scrobbler.lastfm_api_key.is_some()); | ||
| 12 | assert!(scrobbler.lastfm_api_secret.is_some()); | ||
| 13 | assert!(scrobbler.lastfm_session_key.is_some()); | ||
| 14 | assert!(scrobbler.listenbrainz_token.is_some()); | ||
| 15 | } | ||
| 16 | |||
| 17 | #[test] | ||
| 18 | fn test_scrobbler_new_with_none() { | ||
| 19 | let scrobbler = Scrobbler::new(None, None, None, None); | ||
| 20 | assert!(scrobbler.lastfm_api_key.is_none()); | ||
| 21 | assert!(scrobbler.lastfm_api_secret.is_none()); | ||
| 22 | assert!(scrobbler.lastfm_session_key.is_none()); | ||
| 23 | assert!(scrobbler.listenbrainz_token.is_none()); | ||
| 24 | } | ||
| 25 | |||
| 26 | #[test] | ||
| 27 | fn test_scrobbler_now_playing_no_api_key() { | ||
| 28 | let scrobbler = Scrobbler::new(None, None, None, None); | ||
| 29 | scrobbler.now_playing("Artist", "Track", Some("Album")); | ||
| 30 | } | ||
| 31 | |||
| 32 | #[test] | ||
| 33 | fn test_scrobbler_now_playing_with_api_key() { | ||
| 34 | let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); | ||
| 35 | scrobbler.now_playing("Artist", "Track", Some("Album")); | ||
| 36 | } | ||
| 37 | |||
| 38 | #[test] | ||
| 39 | fn test_scrobbler_scrobble_no_keys() { | ||
| 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); | ||
| 47 | scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); | ||
| 48 | } | ||
| 49 | |||
| 50 | #[test] | ||
| 51 | fn test_scrobbler_scrobble_with_listenbrainz() { | ||
| 52 | let scrobbler = Scrobbler::new(None, None, None, Some("token".to_string())); | ||
| 53 | scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); | ||
| 54 | } | ||
| 55 | |||
| 56 | #[test] | ||
| 57 | fn test_scrobbler_scrobble_with_both() { | ||
| 58 | let scrobbler = Scrobbler::new( | ||
| 59 | Some("api_key".to_string()), | ||
| 60 | None, | ||
| 61 | None, | ||
| 62 | Some("token".to_string()), | ||
| 63 | ); | ||
| 64 | scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); | ||
| 65 | } | ||
| 66 | |||
| 67 | #[test] | ||
| 68 | fn test_scrobbler_now_playing_no_album() { | ||
| 69 | let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); | ||
| 70 | scrobbler.now_playing("Artist", "Track", None); | ||
| 71 | } | ||
| 72 | |||
| 73 | #[test] | ||
| 74 | fn test_scrobbler_scrobble_no_album() { | ||
| 75 | let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); | ||
| 76 | scrobbler.scrobble("Artist", "Track", None, 1234567890); | ||
| 77 | } | ||
