diff --git a/src/tests/config.rs b/src/tests/config.rs new file mode 100644 index 0000000..d336192 --- /dev/null +++ b/src/tests/config.rs @@ -0,0 +1,47 @@ +use super::*; + +#[test] +fn load_config() { + //given + let fs = given::a_filesystem(); + let file = fs.base().join(f!("{}.toml", NAME)); + fs.file(&file) + .write( + [ + "[trello]", + "api_key = \"trello-api-key\"", + "api_secret = \"trello-api-secret\"", + "board_name = \"trello-board-name\"", + "", + "[nextcloud]", + "hostname = \"nextcloud-hostname\"", + "username = \"nextcloud-username\"", + "password = \"nextcloud-password\"", + "board_id = 22", + ] + .join("\n"), + ) + .expect("write file"); + let ctx = given::a_context(fs.as_real(), given::a_network().into(), given::a_printer()); + + //when + let_assert!(Ok(config) = AppConfig::load(&ctx)); + + //then + assert_eq!( + config, + AppConfig { + trello: TrelloConfig { + api_key: s!("trello-api-key").into(), + api_secret: s!("trello-api-secret").into(), + board_name: s!("trello-board-name").into(), + }, + nextcloud: NextcloudConfig { + hostname: s!("nextcloud-hostname").into(), + username: s!("nextcloud-username").into(), + password: s!("nextcloud-password").into(), + board_id: 22.into() + } + } + ); +} diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 3e34bd0..1ed14da 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -9,55 +9,7 @@ use crate::{ config::AppConfig, f, init::run, nextcloud::NextcloudConfig, s, trello::TrelloConfig, Ctx, NAME, }; -mod config { - use super::*; - - #[test] - fn load_config() { - //given - let fs = given::a_filesystem(); - let file = fs.base().join(f!("{}.toml", NAME)); - fs.file(&file) - .write( - [ - "[trello]", - "api_key = \"trello-api-key\"", - "api_secret = \"trello-api-secret\"", - "board_name = \"trello-board-name\"", - "", - "[nextcloud]", - "hostname = \"nextcloud-hostname\"", - "username = \"nextcloud-username\"", - "password = \"nextcloud-password\"", - "board_id = 22", - ] - .join("\n"), - ) - .expect("write file"); - let ctx = given::a_context(fs.as_real(), given::a_network().into(), given::a_printer()); - - //when - let_assert!(Ok(config) = AppConfig::load(&ctx)); - - //then - assert_eq!( - config, - AppConfig { - trello: TrelloConfig { - api_key: s!("trello-api-key").into(), - api_secret: s!("trello-api-secret").into(), - board_name: s!("trello-board-name").into(), - }, - nextcloud: NextcloudConfig { - hostname: s!("nextcloud-hostname").into(), - username: s!("nextcloud-username").into(), - password: s!("nextcloud-password").into(), - board_id: 22.into() - } - } - ); - } -} +mod config; mod init { use super::*;