mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-20 17:11:19 +02:00
feature(test): add tests
This commit is contained in:
1
tests/bad_test.toml
Normal file
1
tests/bad_test.toml
Normal file
@@ -0,0 +1 @@
|
||||
blah
|
33
tests/config.rs
Normal file
33
tests/config.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use scootaloo::parse_toml;
|
||||
|
||||
#[test]
|
||||
fn test_parse_good_toml() {
|
||||
let parse_good_toml = parse_toml("tests/good_test.toml");
|
||||
|
||||
assert_eq!(parse_good_toml.scootaloo.db_path, "/var/random/scootaloo.sqlite");
|
||||
assert_eq!(parse_good_toml.scootaloo.cache_path, "/tmp/scootaloo");
|
||||
|
||||
assert_eq!(parse_good_toml.twitter.username, "tamerelol");
|
||||
assert_eq!(parse_good_toml.twitter.consumer_key, "rand consumer key");
|
||||
assert_eq!(parse_good_toml.twitter.consumer_secret, "secret");
|
||||
assert_eq!(parse_good_toml.twitter.access_key, "rand access key");
|
||||
assert_eq!(parse_good_toml.twitter.access_secret, "super secret");
|
||||
|
||||
assert_eq!(parse_good_toml.mastodon.base, "https://m.nintendojo.fr");
|
||||
assert_eq!(parse_good_toml.mastodon.client_id, "rand client id");
|
||||
assert_eq!(parse_good_toml.mastodon.client_secret, "secret");
|
||||
assert_eq!(parse_good_toml.mastodon.redirect, "urn:ietf:wg:oauth:2.0:oob");
|
||||
assert_eq!(parse_good_toml.mastodon.token, "super secret");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "Cannot open config file tests/no_file.toml: No such file or directory (os error 2)")]
|
||||
fn test_parse_no_toml() {
|
||||
let _parse_no_toml = parse_toml("tests/no_file.toml");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "Cannot parse TOML file tests/bad_test.toml: expected an equals, found a newline at line 1 column 5")]
|
||||
fn test_parse_bad_toml() {
|
||||
let _parse_bad_toml = parse_toml("tests/bad_test.toml");
|
||||
}
|
19
tests/good_test.toml
Normal file
19
tests/good_test.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
[scootaloo]
|
||||
|
||||
db_path="/var/random/scootaloo.sqlite"
|
||||
cache_path="/tmp/scootaloo"
|
||||
|
||||
[twitter]
|
||||
username="tamerelol"
|
||||
|
||||
consumer_key="rand consumer key"
|
||||
consumer_secret="secret"
|
||||
access_key="rand access key"
|
||||
access_secret="super secret"
|
||||
|
||||
[mastodon]
|
||||
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