diff options
| author | a14m <[email protected]> | 2021-04-09 16:29:51 +0200 |
|---|---|---|
| committer | a14m <[email protected]> | 2021-04-09 16:29:51 +0200 |
| commit | 4bb3907a505ecbb29848e31aed7ced686757bf6f (patch) | |
| tree | 87288f7e346cf94eb1a87b35ce4b868b51bc15af /CLI | |
| parent | 1a13d563c5a69a9ae05da6fde813db6321a50251 (diff) | |
Mock validators on CI (and allow more control over testing)
Diffstat (limited to 'CLI')
| -rw-r--r-- | CLI/rust/src/game_of_life.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/CLI/rust/src/game_of_life.rs b/CLI/rust/src/game_of_life.rs index 383d564..affe003 100644 --- a/CLI/rust/src/game_of_life.rs +++ b/CLI/rust/src/game_of_life.rs @@ -85,6 +85,7 @@ pub(crate) fn app() -> App<'static> { #[cfg(test)] mod app { use super::*; + use mocktopus::mocking::*; #[test] fn no_options() { @@ -119,24 +120,32 @@ mod app { #[test] fn valid_width() { let matches = app().get_matches_from(vec!["", "--width=13"]); + validators::is_fitting_term_width.mock_safe(|_| MockResult::Return(Ok(()))); + validators::is_fitting_term_height.mock_safe(|_| MockResult::Return(Ok(()))); assert_eq!(matches.value_of("width"), Some("13")); } #[test] fn valid_height() { let matches = app().get_matches_from(vec!["", "--height=13"]); + validators::is_fitting_term_width.mock_safe(|_| MockResult::Return(Ok(()))); + validators::is_fitting_term_height.mock_safe(|_| MockResult::Return(Ok(()))); assert_eq!(matches.value_of("height"), Some("13")); } #[test] fn invalid_width() { let matches = app().try_get_matches_from(vec!["", "--width=1337"]); + validators::is_fitting_term_width.mock_safe(|_| MockResult::Return(Err(String::from("Invalid")))); + validators::is_fitting_term_height.mock_safe(|_| MockResult::Return(Ok(()))); assert!(matches.is_err()); } #[test] fn invalid_height() { let matches = app().try_get_matches_from(vec!["", "--height=1337"]); + validators::is_fitting_term_width.mock_safe(|_| MockResult::Return(Ok(()))); + validators::is_fitting_term_height.mock_safe(|_| MockResult::Return(Err(String::from("Invalid")))); assert!(matches.is_err()); } |
