mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-20 17:11:19 +02:00
test: add tests for scootaloo alt services + regexp
This commit is contained in:
@@ -36,6 +36,8 @@ pub struct ScootalooConfig {
|
|||||||
pub db_path: String,
|
pub db_path: String,
|
||||||
pub cache_path: String,
|
pub cache_path: String,
|
||||||
pub rate_limit: Option<usize>,
|
pub rate_limit: Option<usize>,
|
||||||
|
pub show_url_as_display_url_for: Option<String>,
|
||||||
|
pub alternative_services_for: Option<HashMap<String, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses the TOML file into a Config Struct
|
/// Parses the TOML file into a Config Struct
|
||||||
|
@@ -1,4 +1,33 @@
|
|||||||
use scootaloo::parse_toml;
|
use scootaloo::parse_toml;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_alt_services() {
|
||||||
|
let toml = parse_toml("tests/no_test_alt_services.toml");
|
||||||
|
assert_eq!(toml.scootaloo.alternative_services_for, None);
|
||||||
|
|
||||||
|
let toml = parse_toml("tests/test_alt_services.toml");
|
||||||
|
assert_eq!(
|
||||||
|
toml.scootaloo.alternative_services_for,
|
||||||
|
Some(HashMap::from([
|
||||||
|
("tamere.lol".to_string(), "tonpere.mdr".to_string()),
|
||||||
|
("you.pi".to_string(), "you.pla".to_string())
|
||||||
|
]))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_re_display() {
|
||||||
|
let toml = parse_toml("tests/no_show_url_as_display_url_for.toml");
|
||||||
|
assert_eq!(toml.scootaloo.show_url_as_display_url_for, None);
|
||||||
|
|
||||||
|
let toml = parse_toml("tests/show_url_as_display_url_for.toml");
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
toml.scootaloo.show_url_as_display_url_for,
|
||||||
|
Some("^(.+)\\.es$".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_page_size() {
|
fn test_page_size() {
|
||||||
|
19
tests/no_show_url_as_display_url_for.toml
Normal file
19
tests/no_show_url_as_display_url_for.toml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
[scootaloo]
|
||||||
|
|
||||||
|
db_path="/var/random/scootaloo.sqlite"
|
||||||
|
cache_path="/tmp/scootaloo"
|
||||||
|
|
||||||
|
[twitter]
|
||||||
|
consumer_key="rand consumer key"
|
||||||
|
consumer_secret="secret"
|
||||||
|
access_key="rand access key"
|
||||||
|
access_secret="super secret"
|
||||||
|
|
||||||
|
[mastodon]
|
||||||
|
[mastodon.tamerelol]
|
||||||
|
twitter_screen_name="tamerelol"
|
||||||
|
base = "https://m.nintendojo.fr"
|
||||||
|
client_id = "rand client id"
|
||||||
|
client_secret = "secret"
|
||||||
|
redirect = "urn:ietf:wg:oauth:2.0:oob"
|
||||||
|
token = "super secret"
|
19
tests/no_test_alt_services.toml
Normal file
19
tests/no_test_alt_services.toml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
[scootaloo]
|
||||||
|
|
||||||
|
db_path="/var/random/scootaloo.sqlite"
|
||||||
|
cache_path="/tmp/scootaloo"
|
||||||
|
|
||||||
|
[twitter]
|
||||||
|
consumer_key="rand consumer key"
|
||||||
|
consumer_secret="secret"
|
||||||
|
access_key="rand access key"
|
||||||
|
access_secret="super secret"
|
||||||
|
|
||||||
|
[mastodon]
|
||||||
|
[mastodon.tamerelol]
|
||||||
|
twitter_screen_name="tamerelol"
|
||||||
|
base = "https://m.nintendojo.fr"
|
||||||
|
client_id = "rand client id"
|
||||||
|
client_secret = "secret"
|
||||||
|
redirect = "urn:ietf:wg:oauth:2.0:oob"
|
||||||
|
token = "super secret"
|
20
tests/show_url_as_display_url_for.toml
Normal file
20
tests/show_url_as_display_url_for.toml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
[scootaloo]
|
||||||
|
|
||||||
|
db_path="/var/random/scootaloo.sqlite"
|
||||||
|
cache_path="/tmp/scootaloo"
|
||||||
|
show_url_as_display_url_for = "^(.+)\\.es$"
|
||||||
|
|
||||||
|
[twitter]
|
||||||
|
consumer_key="rand consumer key"
|
||||||
|
consumer_secret="secret"
|
||||||
|
access_key="rand access key"
|
||||||
|
access_secret="super secret"
|
||||||
|
|
||||||
|
[mastodon]
|
||||||
|
[mastodon.tamerelol]
|
||||||
|
twitter_screen_name="tamerelol"
|
||||||
|
base = "https://m.nintendojo.fr"
|
||||||
|
client_id = "rand client id"
|
||||||
|
client_secret = "secret"
|
||||||
|
redirect = "urn:ietf:wg:oauth:2.0:oob"
|
||||||
|
token = "super secret"
|
22
tests/test_alt_services.toml
Normal file
22
tests/test_alt_services.toml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
[scootaloo]
|
||||||
|
|
||||||
|
db_path="/var/random/scootaloo.sqlite"
|
||||||
|
cache_path="/tmp/scootaloo"
|
||||||
|
[scootaloo.alternative_services_for]
|
||||||
|
"tamere.lol" = "tonpere.mdr"
|
||||||
|
"you.pi" = "you.pla"
|
||||||
|
|
||||||
|
[twitter]
|
||||||
|
consumer_key="rand consumer key"
|
||||||
|
consumer_secret="secret"
|
||||||
|
access_key="rand access key"
|
||||||
|
access_secret="super secret"
|
||||||
|
|
||||||
|
[mastodon]
|
||||||
|
[mastodon.tamerelol]
|
||||||
|
twitter_screen_name="tamerelol"
|
||||||
|
base = "https://m.nintendojo.fr"
|
||||||
|
client_id = "rand client id"
|
||||||
|
client_secret = "secret"
|
||||||
|
redirect = "urn:ietf:wg:oauth:2.0:oob"
|
||||||
|
token = "super secret"
|
Reference in New Issue
Block a user