1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
use rsp::scrobbler::Scrobbler;
#[test]
fn test_scrobbler_new_with_all_params() {
let scrobbler = Scrobbler::new(
Some("api_key".to_string()),
Some("secret".to_string()),
Some("session".to_string()),
Some("token".to_string()),
);
assert!(scrobbler.lastfm_api_key.is_some());
assert!(scrobbler.lastfm_api_secret.is_some());
assert!(scrobbler.lastfm_session_key.is_some());
assert!(scrobbler.listenbrainz_token.is_some());
}
#[test]
fn test_scrobbler_new_with_none() {
let scrobbler = Scrobbler::new(None, None, None, None);
assert!(scrobbler.lastfm_api_key.is_none());
assert!(scrobbler.lastfm_api_secret.is_none());
assert!(scrobbler.lastfm_session_key.is_none());
assert!(scrobbler.listenbrainz_token.is_none());
}
#[test]
fn test_scrobbler_now_playing_no_api_key() {
let scrobbler = Scrobbler::new(None, None, None, None);
scrobbler.now_playing("Artist", "Track", Some("Album"));
}
#[test]
fn test_scrobbler_now_playing_with_api_key() {
let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None);
scrobbler.now_playing("Artist", "Track", Some("Album"));
}
#[test]
fn test_scrobbler_scrobble_no_keys() {
let scrobbler = Scrobbler::new(None, None, None, None);
scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890);
}
#[test]
fn test_scrobbler_scrobble_with_lastfm() {
let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None);
scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890);
}
#[test]
fn test_scrobbler_scrobble_with_listenbrainz() {
let scrobbler = Scrobbler::new(None, None, None, Some("token".to_string()));
scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890);
}
#[test]
fn test_scrobbler_scrobble_with_both() {
let scrobbler = Scrobbler::new(
Some("api_key".to_string()),
None,
None,
Some("token".to_string()),
);
scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890);
}
#[test]
fn test_scrobbler_now_playing_no_album() {
let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None);
scrobbler.now_playing("Artist", "Track", None);
}
#[test]
fn test_scrobbler_scrobble_no_album() {
let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None);
scrobbler.scrobble("Artist", "Track", None, 1234567890);
}
|