aboutsummaryrefslogtreecommitdiffstats
path: root/tests/scrobbler.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/scrobbler.rs77
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 @@
1use rsp::scrobbler::Scrobbler;
2
3#[test]
4fn 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]
18fn 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]
27fn 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]
33fn 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]
39fn 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]
45fn 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]
51fn 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]
57fn 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]
68fn 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]
74fn 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}