mirror of
https://framagit.org/veretcle/tootube.git
synced 2025-12-06 08:33:14 +01:00
🔧: add youtube option/put youtube oauth2 in its own struct
This commit is contained in:
@@ -40,6 +40,13 @@ pub struct PeertubeConfigOauth2 {
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct YoutubeConfig {
|
||||
#[serde(default)]
|
||||
pub notify_subscribers_on_shorts: bool,
|
||||
pub oauth2: YoutubeConfigOauth2,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct YoutubeConfigOauth2 {
|
||||
pub refresh_token: String,
|
||||
pub client_id: String,
|
||||
pub client_secret: String,
|
||||
@@ -79,3 +86,33 @@ impl Config {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::fs::{remove_file, write};
|
||||
|
||||
#[test]
|
||||
fn test_minimal_conf() {
|
||||
let file_name = "/tmp/test_minimal_conf.toml";
|
||||
let data = r#"
|
||||
[peertube]
|
||||
base_url = 'https://p.nintendojo.fr'
|
||||
|
||||
[youtube.oauth2]
|
||||
refresh_token = 'rt_N/A'
|
||||
client_id = 'ci_N/A'
|
||||
client_secret = 'cs_N/A'
|
||||
"#;
|
||||
write(file_name, data).unwrap();
|
||||
let config = Config::new(file_name);
|
||||
|
||||
assert_eq!(config.youtube.notify_subscribers_on_shorts, false);
|
||||
assert_eq!(config.tootube.progress_chars, "#>-");
|
||||
assert_eq!(config.youtube.oauth2.refresh_token, "rt_N/A");
|
||||
assert_eq!(config.youtube.oauth2.client_id, "ci_N/A");
|
||||
assert_eq!(config.youtube.oauth2.client_secret, "cs_N/A");
|
||||
|
||||
remove_file(file_name).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user