From 04d1332f9cffda9d0271ad99ac50bec17e918eaf Mon Sep 17 00:00:00 2001 From: David Knaack Date: Thu, 11 Feb 2021 21:08:17 +0100 Subject: [PATCH] refactor(clippy): fix new lints (#2297) --- src/modules/aws.rs | 42 ++++++++---------------- src/modules/character.rs | 21 +++--------- src/modules/cmd_duration.rs | 19 ++++------- src/modules/conda.rs | 13 +++----- src/modules/directory.rs | 39 ++++++++-------------- src/modules/dotnet.rs | 32 +++++++++---------- src/modules/env_var.rs | 25 +++++---------- src/modules/git_status.rs | 1 + src/modules/hg_branch.rs | 19 ++++++----- src/modules/hostname.rs | 18 ++++------- src/modules/jobs.rs | 16 +++------- src/modules/line_break.rs | 6 +--- src/modules/nix_shell.rs | 19 ++++------- src/modules/package.rs | 64 +++++++++++++++++-------------------- src/modules/ruby.rs | 4 +-- src/modules/shlvl.rs | 31 ++++++------------ src/modules/singularity.rs | 7 ++-- src/modules/status.rs | 32 +++++-------------- src/modules/time.rs | 10 ++---- src/modules/username.rs | 28 ++++++---------- 20 files changed, 155 insertions(+), 291 deletions(-) diff --git a/src/modules/aws.rs b/src/modules/aws.rs index 0898d9e2..ed667d69 100644 --- a/src/modules/aws.rs +++ b/src/modules/aws.rs @@ -125,16 +125,15 @@ mod tests { #[test] #[ignore] - fn no_region_set() -> io::Result<()> { + fn no_region_set() { let actual = ModuleRenderer::new("aws").collect(); let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn region_set() -> io::Result<()> { + fn region_set() { let actual = ModuleRenderer::new("aws") .env("AWS_REGION", "ap-northeast-2") .collect(); @@ -144,11 +143,10 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn region_set_with_alias() -> io::Result<()> { + fn region_set_with_alias() { let actual = ModuleRenderer::new("aws") .env("AWS_REGION", "ap-southeast-2") .config(toml::toml! { @@ -159,11 +157,10 @@ mod tests { let expected = Some(format!("on {} ", Color::Yellow.bold().paint("☁️ (au)"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn default_region_set() -> io::Result<()> { + fn default_region_set() { let actual = ModuleRenderer::new("aws") .env("AWS_REGION", "ap-northeast-2") .env("AWS_DEFAULT_REGION", "ap-northeast-1") @@ -174,11 +171,10 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn profile_set() -> io::Result<()> { + fn profile_set() { let actual = ModuleRenderer::new("aws") .env("AWS_PROFILE", "astronauts") .collect(); @@ -188,11 +184,10 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn profile_set_from_aws_vault() -> io::Result<()> { + fn profile_set_from_aws_vault() { let actual = ModuleRenderer::new("aws") .env("AWS_VAULT", "astronauts-vault") .env("AWS_PROFILE", "astronauts-profile") @@ -203,11 +198,10 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn profile_and_region_set() -> io::Result<()> { + fn profile_and_region_set() { let actual = ModuleRenderer::new("aws") .env("AWS_PROFILE", "astronauts") .env("AWS_REGION", "ap-northeast-2") @@ -218,7 +212,6 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } #[test] @@ -282,7 +275,7 @@ region = us-east-2 } #[test] - fn profile_and_region_set_with_display_all() -> io::Result<()> { + fn profile_and_region_set_with_display_all() { let actual = ModuleRenderer::new("aws") .env("AWS_PROFILE", "astronauts") .env("AWS_REGION", "ap-northeast-1") @@ -293,11 +286,10 @@ region = us-east-2 )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn profile_set_with_display_all() -> io::Result<()> { + fn profile_set_with_display_all() { let actual = ModuleRenderer::new("aws") .env("AWS_PROFILE", "astronauts") .collect(); @@ -307,11 +299,10 @@ region = us-east-2 )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn region_set_with_display_all() -> io::Result<()> { + fn region_set_with_display_all() { let actual = ModuleRenderer::new("aws") .env("AWS_REGION", "ap-northeast-1") .collect(); @@ -321,11 +312,10 @@ region = us-east-2 )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn profile_and_region_set_with_display_region() -> io::Result<()> { + fn profile_and_region_set_with_display_region() { let actual = ModuleRenderer::new("aws") .env("AWS_PROFILE", "astronauts") .env("AWS_DEFAULT_REGION", "ap-northeast-1") @@ -340,11 +330,10 @@ region = us-east-2 )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn profile_and_region_set_with_display_profile() -> io::Result<()> { + fn profile_and_region_set_with_display_profile() { let actual = ModuleRenderer::new("aws") .env("AWS_PROFILE", "astronauts") .env("AWS_REGION", "ap-northeast-1") @@ -359,11 +348,10 @@ region = us-east-2 )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn region_set_with_display_profile() -> io::Result<()> { + fn region_set_with_display_profile() { let actual = ModuleRenderer::new("aws") .env("AWS_REGION", "ap-northeast-1") .config(toml::toml! { @@ -374,12 +362,11 @@ region = us-east-2 let expected = Some(format!("on {} ", Color::Yellow.bold().paint("☁️ "))); assert_eq!(expected, actual); - Ok(()) } #[test] #[ignore] - fn region_not_set_with_display_region() -> io::Result<()> { + fn region_not_set_with_display_region() { let actual = ModuleRenderer::new("aws") .config(toml::toml! { [aws] @@ -389,6 +376,5 @@ region = us-east-2 let expected = None; assert_eq!(expected, actual); - Ok(()) } } diff --git a/src/modules/character.rs b/src/modules/character.rs index dd397ec0..17b373a9 100644 --- a/src/modules/character.rs +++ b/src/modules/character.rs @@ -74,10 +74,9 @@ mod test { use crate::context::Shell; use crate::test::ModuleRenderer; use ansi_term::Color; - use std::io; #[test] - fn success_status() -> io::Result<()> { + fn success_status() { let expected = Some(format!("{} ", Color::Green.bold().paint("❯"))); // Status code 0 @@ -87,12 +86,10 @@ mod test { // No status code let actual = ModuleRenderer::new("character").collect(); assert_eq!(expected, actual); - - Ok(()) } #[test] - fn failure_status() -> io::Result<()> { + fn failure_status() { let expected = Some(format!("{} ", Color::Red.bold().paint("❯"))); let exit_values = [1, 54321, -5000]; @@ -101,12 +98,10 @@ mod test { let actual = ModuleRenderer::new("character").status(*status).collect(); assert_eq!(expected, actual); } - - Ok(()) } #[test] - fn custom_symbol() -> io::Result<()> { + fn custom_symbol() { let expected_fail = Some(format!("{} ", Color::Red.bold().paint("✖"))); let expected_success = Some(format!("{} ", Color::Green.bold().paint("➜"))); @@ -135,12 +130,10 @@ mod test { .status(0) .collect(); assert_eq!(expected_success, actual); - - Ok(()) } #[test] - fn zsh_keymap() -> io::Result<()> { + fn zsh_keymap() { let expected_vicmd = Some(format!("{} ", Color::Green.bold().paint("❮"))); let expected_specified = Some(format!("{} ", Color::Green.bold().paint("V"))); let expected_other = Some(format!("{} ", Color::Green.bold().paint("❯"))); @@ -169,12 +162,10 @@ mod test { .keymap("visual") .collect(); assert_eq!(expected_other, actual); - - Ok(()) } #[test] - fn fish_keymap() -> io::Result<()> { + fn fish_keymap() { let expected_vicmd = Some(format!("{} ", Color::Green.bold().paint("❮"))); let expected_specified = Some(format!("{} ", Color::Green.bold().paint("V"))); let expected_other = Some(format!("{} ", Color::Green.bold().paint("❯"))); @@ -203,7 +194,5 @@ mod test { .keymap("visual") .collect(); assert_eq!(expected_other, actual); - - Ok(()) } } diff --git a/src/modules/cmd_duration.rs b/src/modules/cmd_duration.rs index 1fe03ada..1d732d29 100644 --- a/src/modules/cmd_duration.rs +++ b/src/modules/cmd_duration.rs @@ -128,7 +128,6 @@ mod tests { use super::*; use crate::test::ModuleRenderer; use ansi_term::Color; - use std::io; #[test] fn test_500ms() { @@ -152,29 +151,27 @@ mod tests { } #[test] - fn config_blank_duration_1s() -> io::Result<()> { + fn config_blank_duration_1s() { let actual = ModuleRenderer::new("cmd_duration") .cmd_duration(1000) .collect(); let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn config_blank_duration_5s() -> io::Result<()> { + fn config_blank_duration_5s() { let actual = ModuleRenderer::new("cmd_duration") .cmd_duration(5000) .collect(); let expected = Some(format!("took {} ", Color::Yellow.bold().paint("5s"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn config_5s_duration_3s() -> io::Result<()> { + fn config_5s_duration_3s() { let actual = ModuleRenderer::new("cmd_duration") .config(toml::toml! { [cmd_duration] @@ -185,11 +182,10 @@ mod tests { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn config_5s_duration_10s() -> io::Result<()> { + fn config_5s_duration_10s() { let actual = ModuleRenderer::new("cmd_duration") .config(toml::toml! { [cmd_duration] @@ -200,11 +196,10 @@ mod tests { let expected = Some(format!("took {} ", Color::Yellow.bold().paint("10s"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn config_1s_duration_prefix_underwent() -> io::Result<()> { + fn config_1s_duration_prefix_underwent() { let actual = ModuleRenderer::new("cmd_duration") .config(toml::toml! { [cmd_duration] @@ -215,11 +210,10 @@ mod tests { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn config_5s_duration_prefix_underwent() -> io::Result<()> { + fn config_5s_duration_prefix_underwent() { let actual = ModuleRenderer::new("cmd_duration") .config(toml::toml! { [cmd_duration] @@ -230,6 +224,5 @@ mod tests { let expected = Some(format!("underwent {} ", Color::Yellow.bold().paint("5s"))); assert_eq!(expected, actual); - Ok(()) } } diff --git a/src/modules/conda.rs b/src/modules/conda.rs index 36762c4c..70878b73 100644 --- a/src/modules/conda.rs +++ b/src/modules/conda.rs @@ -57,20 +57,18 @@ pub fn module<'a>(context: &'a Context) -> Option> { mod tests { use crate::test::ModuleRenderer; use ansi_term::Color; - use std::io; #[test] - fn not_in_env() -> io::Result<()> { + fn not_in_env() { let actual = ModuleRenderer::new("conda").collect(); let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn ignore_base() -> io::Result<()> { + fn ignore_base() { let actual = ModuleRenderer::new("conda") .env("CONDA_DEFAULT_ENV", "base") .config(toml::toml! { @@ -82,11 +80,10 @@ mod tests { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn env_set() -> io::Result<()> { + fn env_set() { let actual = ModuleRenderer::new("conda") .env("CONDA_DEFAULT_ENV", "astronauts") .collect(); @@ -97,11 +94,10 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn truncate() -> io::Result<()> { + fn truncate() { let actual = ModuleRenderer::new("conda") .env("CONDA_DEFAULT_ENV", "/some/really/long/and/really/annoying/path/that/shouldnt/be/displayed/fully/conda/my_env") .collect(); @@ -109,6 +105,5 @@ mod tests { let expected = Some(format!("via {} ", Color::Green.bold().paint("🅒 my_env"))); assert_eq!(expected, actual); - Ok(()) } } diff --git a/src/modules/directory.rs b/src/modules/directory.rs index 7dcd03ec..721f7827 100644 --- a/src/modules/directory.rs +++ b/src/modules/directory.rs @@ -515,7 +515,7 @@ mod tests { } #[test] - fn directory_in_root() -> io::Result<()> { + fn directory_in_root() { let actual = ModuleRenderer::new("directory").path("/etc").collect(); let expected = Some(format!( "{}{} ", @@ -524,23 +524,21 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } } #[test] - fn home_directory_default_home_symbol() -> io::Result<()> { + fn home_directory_default_home_symbol() { let actual = ModuleRenderer::new("directory") .path(home_dir().unwrap()) .collect(); let expected = Some(format!("{} ", Color::Cyan.bold().paint("~"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn home_directory_custom_home_symbol() -> io::Result<()> { + fn home_directory_custom_home_symbol() { let actual = ModuleRenderer::new("directory") .path(home_dir().unwrap()) .config(toml::toml! { @@ -551,11 +549,10 @@ mod tests { let expected = Some(format!("{} ", Color::Cyan.bold().paint("🚀"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn home_directory_custom_home_symbol_subdirectories() -> io::Result<()> { + fn home_directory_custom_home_symbol_subdirectories() { let actual = ModuleRenderer::new("directory") .path(home_dir().unwrap().join("path/subpath")) .config(toml::toml! { @@ -566,11 +563,10 @@ mod tests { let expected = Some(format!("{} ", Color::Cyan.bold().paint("🚀/path/subpath"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn substituted_truncated_path() -> io::Result<()> { + fn substituted_truncated_path() { let actual = ModuleRenderer::new("directory") .path("/some/long/network/path/workspace/a/b/c/dev") .config(toml::toml! { @@ -587,11 +583,10 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn substitution_order() -> io::Result<()> { + fn substitution_order() { let actual = ModuleRenderer::new("directory") .path("/path/to/sub") .config(toml::toml! { @@ -603,11 +598,10 @@ mod tests { let expected = Some(format!("{} ", Color::Cyan.bold().paint("/correct/order"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn strange_substitution() -> io::Result<()> { + fn strange_substitution() { let strange_sub = "/\\/;,!"; let actual = ModuleRenderer::new("directory") .path("/foo/bar/regular/path") @@ -627,7 +621,6 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } #[test] @@ -690,7 +683,7 @@ mod tests { } #[test] - fn root_directory() -> io::Result<()> { + fn root_directory() { let actual = ModuleRenderer::new("directory").path("/").collect(); #[cfg(not(target_os = "windows"))] let expected = Some(format!( @@ -702,7 +695,6 @@ mod tests { let expected = Some(format!("{} ", Color::Cyan.bold().paint("/"))); assert_eq!(expected, actual); - Ok(()) } #[test] @@ -1234,7 +1226,7 @@ mod tests { } #[test] - fn truncation_symbol_truncated_root() -> io::Result<()> { + fn truncation_symbol_truncated_root() { let actual = ModuleRenderer::new("directory") .config(toml::toml! { [directory] @@ -1248,11 +1240,10 @@ mod tests { Color::Cyan.bold().paint("…/four/element/path") )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn truncation_symbol_not_truncated_root() -> io::Result<()> { + fn truncation_symbol_not_truncated_root() { let actual = ModuleRenderer::new("directory") .config(toml::toml! { [directory] @@ -1266,7 +1257,6 @@ mod tests { Color::Cyan.bold().paint("/a/four/element/path") )); assert_eq!(expected, actual); - Ok(()) } #[test] @@ -1362,7 +1352,7 @@ mod tests { #[test] #[cfg(target_os = "windows")] - fn truncation_symbol_windows_root_not_truncated() -> io::Result<()> { + fn truncation_symbol_windows_root_not_truncated() { let dir = Path::new("C:\\temp"); let actual = ModuleRenderer::new("directory") .config(toml::toml! { @@ -1374,12 +1364,11 @@ mod tests { .collect(); let expected = Some(format!("{} ", Color::Cyan.bold().paint("C:/temp"))); assert_eq!(expected, actual); - Ok(()) } #[test] #[cfg(target_os = "windows")] - fn truncation_symbol_windows_root_truncated() -> io::Result<()> { + fn truncation_symbol_windows_root_truncated() { let dir = Path::new("C:\\temp"); let actual = ModuleRenderer::new("directory") .config(toml::toml! { @@ -1391,12 +1380,11 @@ mod tests { .collect(); let expected = Some(format!("{} ", Color::Cyan.bold().paint("…/temp"))); assert_eq!(expected, actual); - Ok(()) } #[test] #[cfg(target_os = "windows")] - fn truncation_symbol_windows_root_truncated_backslash() -> io::Result<()> { + fn truncation_symbol_windows_root_truncated_backslash() { let dir = Path::new("C:\\temp"); let actual = ModuleRenderer::new("directory") .config(toml::toml! { @@ -1408,7 +1396,6 @@ mod tests { .collect(); let expected = Some(format!("{} ", Color::Cyan.bold().paint("…\\temp"))); assert_eq!(expected, actual); - Ok(()) } #[test] diff --git a/src/modules/dotnet.rs b/src/modules/dotnet.rs index eea1bdbc..8bb64768 100644 --- a/src/modules/dotnet.rs +++ b/src/modules/dotnet.rs @@ -366,7 +366,7 @@ mod tests { #[test] fn shows_nothing_in_directory_with_zero_relevant_files() -> io::Result<()> { let workspace = create_workspace(false)?; - expect_output(&workspace.path(), None)?; + expect_output(&workspace.path(), None); workspace.close() } @@ -377,7 +377,7 @@ mod tests { expect_output( &workspace.path(), Some(format!("{}", Color::Blue.bold().paint("•NET v3.1.103 "))), - )?; + ); workspace.close() } @@ -388,7 +388,7 @@ mod tests { expect_output( &workspace.path(), Some(format!("{}", Color::Blue.bold().paint("•NET v3.1.103 "))), - )?; + ); workspace.close() } @@ -399,7 +399,7 @@ mod tests { expect_output( &workspace.path(), Some(format!("{}", Color::Blue.bold().paint("•NET v3.1.103 "))), - )?; + ); workspace.close() } @@ -410,7 +410,7 @@ mod tests { expect_output( &workspace.path(), Some(format!("{}", Color::Blue.bold().paint("•NET v3.1.103 "))), - )?; + ); workspace.close() } @@ -425,7 +425,7 @@ mod tests { "{}", Color::Blue.bold().paint("•NET v3.1.103 🎯 netstandard2.0 ") )), - )?; + ); workspace.close() } @@ -436,7 +436,7 @@ mod tests { expect_output( &workspace.path(), Some(format!("{}", Color::Blue.bold().paint("•NET v3.1.103 "))), - )?; + ); workspace.close() } @@ -447,7 +447,7 @@ mod tests { expect_output( &workspace.path(), Some(format!("{}", Color::Blue.bold().paint("•NET v3.1.103 "))), - )?; + ); workspace.close() } @@ -458,7 +458,7 @@ mod tests { expect_output( &workspace.path(), Some(format!("{}", Color::Blue.bold().paint("•NET v3.1.103 "))), - )?; + ); workspace.close() } @@ -470,7 +470,7 @@ mod tests { expect_output( &workspace.path(), Some(format!("{}", Color::Blue.bold().paint("•NET v1.2.3 "))), - )?; + ); workspace.close() } @@ -487,7 +487,7 @@ mod tests { "{}", Color::Blue.bold().paint("•NET v1.2.3 🎯 netstandard2.0 ") )), - )?; + ); workspace.close() } @@ -508,7 +508,7 @@ mod tests { "{}", Color::Blue.bold().paint("•NET v1.2.3 🎯 netstandard2.0 ") )), - )?; + ); workspace.close() } @@ -523,7 +523,7 @@ mod tests { "{}", Color::Blue.bold().paint("•NET v3.1.103 🎯 netstandard2.0 ") )), - )?; + ); workspace.close() } @@ -540,7 +540,7 @@ mod tests { .bold() .paint("•NET v3.1.103 🎯 netstandard2.0;net461 ") )), - )?; + ); workspace.close() } @@ -602,12 +602,10 @@ mod tests { .replace("TFM_VALUE", tfm) } - fn expect_output(dir: &Path, expected: Option) -> io::Result<()> { + fn expect_output(dir: &Path, expected: Option) { let actual = ModuleRenderer::new("dotnet").path(dir).collect(); assert_eq!(actual, expected); - - Ok(()) } #[test] diff --git a/src/modules/env_var.rs b/src/modules/env_var.rs index 47af5074..819c992d 100644 --- a/src/modules/env_var.rs +++ b/src/modules/env_var.rs @@ -54,12 +54,11 @@ fn get_env_value(context: &Context, name: &str, default: Option<&str>) -> Option mod test { use crate::test::ModuleRenderer; use ansi_term::{Color, Style}; - use std::io; const TEST_VAR_VALUE: &str = "astronauts"; #[test] - fn empty_config() -> io::Result<()> { + fn empty_config() { let actual = ModuleRenderer::new("env_var") .config(toml::toml! { [env_var] @@ -68,11 +67,10 @@ mod test { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn defined_variable() -> io::Result<()> { + fn defined_variable() { let actual = ModuleRenderer::new("env_var") .config(toml::toml! { [env_var] @@ -83,11 +81,10 @@ mod test { let expected = Some(format!("with {} ", style().paint(TEST_VAR_VALUE))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn undefined_variable() -> io::Result<()> { + fn undefined_variable() { let actual = ModuleRenderer::new("env_var") .config(toml::toml! { [env_var] @@ -97,11 +94,10 @@ mod test { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn default_has_no_effect() -> io::Result<()> { + fn default_has_no_effect() { let actual = ModuleRenderer::new("env_var") .config(toml::toml! { [env_var] @@ -113,11 +109,10 @@ mod test { let expected = Some(format!("with {} ", style().paint(TEST_VAR_VALUE))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn default_takes_effect() -> io::Result<()> { + fn default_takes_effect() { let actual = ModuleRenderer::new("env_var") .config(toml::toml! { [env_var] @@ -128,11 +123,10 @@ mod test { let expected = Some(format!("with {} ", style().paint("N/A"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn symbol() -> io::Result<()> { + fn symbol() { let actual = ModuleRenderer::new("env_var") .config(toml::toml! { [env_var] @@ -147,11 +141,10 @@ mod test { )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn prefix() -> io::Result<()> { + fn prefix() { let actual = ModuleRenderer::new("env_var") .config(toml::toml! { [env_var] @@ -166,11 +159,10 @@ mod test { )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn suffix() -> io::Result<()> { + fn suffix() { let actual = ModuleRenderer::new("env_var") .config(toml::toml! { [env_var] @@ -185,7 +177,6 @@ mod test { )); assert_eq!(expected, actual); - Ok(()) } fn style() -> Style { diff --git a/src/modules/git_status.rs b/src/modules/git_status.rs index 22ee628b..ea8f7e76 100644 --- a/src/modules/git_status.rs +++ b/src/modules/git_status.rs @@ -354,6 +354,7 @@ mod tests { std::thread::sleep(std::time::Duration::from_millis(500)); } + #[allow(clippy::unnecessary_wraps)] fn format_output(symbols: &str) -> Option { Some(format!( "{} ", diff --git a/src/modules/hg_branch.rs b/src/modules/hg_branch.rs index 9b6c211a..6dc54f91 100644 --- a/src/modules/hg_branch.rs +++ b/src/modules/hg_branch.rs @@ -143,7 +143,7 @@ mod tests { truncation_length = 14 }), &[Expect::Empty], - )?; + ); tempdir.close() } @@ -161,7 +161,7 @@ mod tests { tempdir.path(), None, &[Expect::BranchName(&"default"), Expect::NoTruncation], - )?; + ); tempdir.close() } @@ -169,7 +169,7 @@ mod tests { #[ignore] fn test_hg_get_branch_autodisabled() -> io::Result<()> { let tempdir = tempfile::tempdir()?; - expect_hg_branch_with_config(tempdir.path(), None, &[Expect::Empty])?; + expect_hg_branch_with_config(tempdir.path(), None, &[Expect::Empty]); tempdir.close() } @@ -183,7 +183,7 @@ mod tests { &repo_dir, None, &[Expect::BranchName(&"bookmark-101"), Expect::NoTruncation], - )?; + ); tempdir.close() } @@ -211,7 +211,7 @@ mod tests { disabled = false }), &[Expect::BranchName(&"branch-name-10")], - )?; + ); tempdir.close() } @@ -245,7 +245,7 @@ mod tests { Expect::Symbol(&"B"), Expect::TruncationSymbol(&"%"), ], - )?; + ); tempdir.close() } @@ -278,7 +278,7 @@ mod tests { Expect::Style(Color::Blue.underline()), Expect::TruncationSymbol(&""), ], - )?; + ); tempdir.close() } @@ -286,7 +286,7 @@ mod tests { repo_dir: &Path, config: Option, expectations: &[Expect], - ) -> io::Result<()> { + ) { let actual = ModuleRenderer::new("hg_branch") .path(repo_dir.to_str().unwrap()) .config(config.unwrap_or_else(|| { @@ -306,7 +306,7 @@ mod tests { match expect { Expect::Empty => { assert_eq!(None, actual); - return Ok(()); + return; } Expect::Symbol(symbol) => { expect_symbol = symbol; @@ -332,7 +332,6 @@ mod tests { )), )); assert_eq!(expected, actual); - Ok(()) } fn run_hg(args: &[&str], repo_dir: &Path) -> io::Result<()> { diff --git a/src/modules/hostname.rs b/src/modules/hostname.rs index bf94eebe..147001b6 100644 --- a/src/modules/hostname.rs +++ b/src/modules/hostname.rs @@ -69,7 +69,6 @@ pub fn module<'a>(context: &'a Context) -> Option> { mod tests { use crate::test::ModuleRenderer; use ansi_term::{Color, Style}; - use std::io; macro_rules! get_hostname { () => { @@ -80,13 +79,13 @@ mod tests { "hostname was not tested because gethostname failed! \ This could be caused by your hostname containing invalid UTF." ); - return Ok(()); + return; } }; } #[test] - fn ssh_only_false() -> io::Result<()> { + fn ssh_only_false() { let hostname = get_hostname!(); let actual = ModuleRenderer::new("hostname") .config(toml::toml! { @@ -98,11 +97,10 @@ mod tests { let expected = Some(format!("{} in ", style().paint(hostname))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn no_ssh() -> io::Result<()> { + fn no_ssh() { let actual = ModuleRenderer::new("hostname") .config(toml::toml! { [hostname] @@ -112,11 +110,10 @@ mod tests { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn ssh() -> io::Result<()> { + fn ssh() { let hostname = get_hostname!(); let actual = ModuleRenderer::new("hostname") .config(toml::toml! { @@ -129,11 +126,10 @@ mod tests { let expected = Some(format!("{} in ", style().paint(hostname))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn no_trim_at() -> io::Result<()> { + fn no_trim_at() { let hostname = get_hostname!(); let actual = ModuleRenderer::new("hostname") .config(toml::toml! { @@ -145,11 +141,10 @@ mod tests { let expected = Some(format!("{} in ", style().paint(hostname))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn trim_at() -> io::Result<()> { + fn trim_at() { let hostname = get_hostname!(); let (remainder, trim_at) = hostname.split_at(1); let actual = ModuleRenderer::new("hostname") @@ -162,7 +157,6 @@ mod tests { let expected = Some(format!("{} in ", style().paint(remainder))); assert_eq!(expected, actual); - Ok(()) } fn style() -> Style { diff --git a/src/modules/jobs.rs b/src/modules/jobs.rs index 65a6ccc2..ecb75aff 100644 --- a/src/modules/jobs.rs +++ b/src/modules/jobs.rs @@ -57,37 +57,33 @@ pub fn module<'a>(context: &'a Context) -> Option> { mod test { use crate::test::ModuleRenderer; use ansi_term::Color; - use std::io; #[test] - fn config_blank_job_0() -> io::Result<()> { + fn config_blank_job_0() { let actual = ModuleRenderer::new("jobs").jobs(0).collect(); let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn config_blank_job_1() -> io::Result<()> { + fn config_blank_job_1() { let actual = ModuleRenderer::new("jobs").jobs(1).collect(); let expected = Some(format!("{} ", Color::Blue.bold().paint("✦"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn config_blank_job_2() -> io::Result<()> { + fn config_blank_job_2() { let actual = ModuleRenderer::new("jobs").jobs(2).collect(); let expected = Some(format!("{} ", Color::Blue.bold().paint("✦2"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn config_2_job_2() -> io::Result<()> { + fn config_2_job_2() { let actual = ModuleRenderer::new("jobs") .config(toml::toml! { [jobs] @@ -98,11 +94,10 @@ mod test { let expected = Some(format!("{} ", Color::Blue.bold().paint("✦"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn config_2_job_3() -> io::Result<()> { + fn config_2_job_3() { let actual = ModuleRenderer::new("jobs") .config(toml::toml! { [jobs] @@ -113,6 +108,5 @@ mod test { let expected = Some(format!("{} ", Color::Blue.bold().paint("✦3"))); assert_eq!(expected, actual); - Ok(()) } } diff --git a/src/modules/line_break.rs b/src/modules/line_break.rs index 944a1c22..4aa67595 100644 --- a/src/modules/line_break.rs +++ b/src/modules/line_break.rs @@ -14,16 +14,12 @@ pub fn module<'a>(context: &'a Context) -> Option> { #[cfg(test)] mod test { - use std::io; - use crate::test::ModuleRenderer; #[test] - fn produces_result() -> io::Result<()> { + fn produces_result() { let expected = Some(String::from("\n")); let actual = ModuleRenderer::new("line_break").collect(); assert_eq!(expected, actual); - - Ok(()) } } diff --git a/src/modules/nix_shell.rs b/src/modules/nix_shell.rs index ab5fba08..f06292cc 100644 --- a/src/modules/nix_shell.rs +++ b/src/modules/nix_shell.rs @@ -64,52 +64,47 @@ pub fn module<'a>(context: &'a Context) -> Option> { mod tests { use crate::test::ModuleRenderer; use ansi_term::Color; - use std::io; #[test] - fn no_env_variables() -> io::Result<()> { + fn no_env_variables() { let actual = ModuleRenderer::new("nix_shell").collect(); let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn invalid_env_variables() -> io::Result<()> { + fn invalid_env_variables() { let actual = ModuleRenderer::new("nix_shell") .env("IN_NIX_SHELL", "something_wrong") .collect(); let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn pure_shell() -> io::Result<()> { + fn pure_shell() { let actual = ModuleRenderer::new("nix_shell") .env("IN_NIX_SHELL", "pure") .collect(); let expected = Some(format!("via {} ", Color::Blue.bold().paint("❄️ pure"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn impure_shell() -> io::Result<()> { + fn impure_shell() { let actual = ModuleRenderer::new("nix_shell") .env("IN_NIX_SHELL", "impure") .collect(); let expected = Some(format!("via {} ", Color::Blue.bold().paint("❄️ impure"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn pure_shell_name() -> io::Result<()> { + fn pure_shell_name() { let actual = ModuleRenderer::new("nix_shell") .env("IN_NIX_SHELL", "pure") .env("name", "starship") @@ -120,11 +115,10 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } #[test] - fn impure_shell_name() -> io::Result<()> { + fn impure_shell_name() { let actual = ModuleRenderer::new("nix_shell") .env("IN_NIX_SHELL", "impure") .env("name", "starship") @@ -135,6 +129,5 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } } diff --git a/src/modules/package.rs b/src/modules/package.rs index 9c412f83..14e7f38d 100644 --- a/src/modules/package.rs +++ b/src/modules/package.rs @@ -244,7 +244,7 @@ mod tests { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.1.0"), None)?; + expect_output(&project_dir, Some("v0.1.0"), None); project_dir.close() } @@ -259,7 +259,7 @@ mod tests { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.1.0"), None)?; + expect_output(&project_dir, Some("v0.1.0"), None); project_dir.close() } @@ -273,7 +273,7 @@ mod tests { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -288,7 +288,7 @@ mod tests { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -303,7 +303,7 @@ mod tests { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -319,7 +319,7 @@ mod tests { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -339,7 +339,7 @@ mod tests { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.1.0"), Some(starship_config))?; + expect_output(&project_dir, Some("v0.1.0"), Some(starship_config)); project_dir.close() } @@ -355,7 +355,7 @@ mod tests { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.1.0"), None)?; + expect_output(&project_dir, Some("v0.1.0"), None); project_dir.close() } @@ -370,7 +370,7 @@ mod tests { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -389,7 +389,7 @@ java { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.1.0"), None)?; + expect_output(&project_dir, Some("v0.1.0"), None); project_dir.close() } @@ -408,7 +408,7 @@ java { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.1.0"), None)?; + expect_output(&project_dir, Some("v0.1.0"), None); project_dir.close() } @@ -427,7 +427,7 @@ java { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.1.0-rc1"), None)?; + expect_output(&project_dir, Some("v0.1.0-rc1"), None); project_dir.close() } @@ -445,7 +445,7 @@ java { let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -478,7 +478,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v1.2.3"), None)?; + expect_output(&project_dir, Some("v1.2.3"), None); project_dir.close() } @@ -489,7 +489,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v3.2.1"), None)?; + expect_output(&project_dir, Some("v3.2.1"), None); project_dir.close() } @@ -505,7 +505,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v1.0.0-alpha.3"), None)?; + expect_output(&project_dir, Some("v1.0.0-alpha.3"), None); project_dir.close() } @@ -521,7 +521,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.9.9-dev+20130417140000.amd64"), None)?; + expect_output(&project_dir, Some("v0.9.9-dev+20130417140000.amd64"), None); project_dir.close() } @@ -536,7 +536,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.2.0"), None)?; + expect_output(&project_dir, Some("v0.2.0"), None); project_dir.close() } @@ -551,7 +551,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.1.0"), None)?; + expect_output(&project_dir, Some("v0.1.0"), None); project_dir.close() } @@ -565,7 +565,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -580,7 +580,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.1.0"), None)?; + expect_output(&project_dir, Some("v0.1.0"), None); project_dir.close() } @@ -594,7 +594,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -668,7 +668,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, "pom.xml", Some(&pom))?; - expect_output(&project_dir, Some("0.3.20-SNAPSHOT"), None)?; + expect_output(&project_dir, Some("0.3.20-SNAPSHOT"), None); project_dir.close() } @@ -692,7 +692,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, "pom.xml", Some(&pom))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -709,7 +709,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, "pom.xml", Some(&pom))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -730,7 +730,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, "pom.xml", Some(&pom))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -741,7 +741,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, Some("v0.1.0"), None)?; + expect_output(&project_dir, Some("v0.1.0"), None); project_dir.close() } @@ -752,7 +752,7 @@ end"; let project_dir = create_project_dir()?; fill_config(&project_dir, config_name, Some(&config_content))?; - expect_output(&project_dir, None, None)?; + expect_output(&project_dir, None, None); project_dir.close() } @@ -770,11 +770,7 @@ end"; file.sync_all() } - fn expect_output( - project_dir: &TempDir, - contains: Option<&str>, - config: Option, - ) -> io::Result<()> { + fn expect_output(project_dir: &TempDir, contains: Option<&str>, config: Option) { let starship_config = config.unwrap_or(toml::toml! { [package] disabled = false @@ -795,7 +791,5 @@ end"; } else { assert_eq!(actual, None); } - - Ok(()) } } diff --git a/src/modules/ruby.rs b/src/modules/ruby.rs index 7e10dbd0..97c4c31e 100644 --- a/src/modules/ruby.rs +++ b/src/modules/ruby.rs @@ -125,7 +125,7 @@ mod tests { } #[test] - fn test_format_ruby_version() -> io::Result<()> { + fn test_format_ruby_version() { assert_eq!( format_ruby_version("ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-darwin19.0]"), Some("v2.1.10".to_string()) @@ -140,7 +140,5 @@ mod tests { ), Some("v2.7.0".to_string()) ); - - Ok(()) } } diff --git a/src/modules/shlvl.rs b/src/modules/shlvl.rs index 4a33d4f7..50e81f39 100644 --- a/src/modules/shlvl.rs +++ b/src/modules/shlvl.rs @@ -64,7 +64,6 @@ pub fn module<'a>(context: &'a Context) -> Option> { #[cfg(test)] mod tests { use ansi_term::{Color, Style}; - use std::io; use crate::test::ModuleRenderer; @@ -76,7 +75,7 @@ mod tests { } #[test] - fn empty_config() -> io::Result<()> { + fn empty_config() { let actual = ModuleRenderer::new("shlvl") .config(toml::toml! { [shlvl] @@ -86,11 +85,10 @@ mod tests { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn enabled() -> io::Result<()> { + fn enabled() { let actual = ModuleRenderer::new("shlvl") .config(toml::toml! { [shlvl] @@ -101,11 +99,10 @@ mod tests { let expected = Some(format!("{} ", style().paint("↕️ 2"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn no_level() -> io::Result<()> { + fn no_level() { let actual = ModuleRenderer::new("shlvl") .config(toml::toml! { [shlvl] @@ -115,11 +112,10 @@ mod tests { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn enabled_config_level_1() -> io::Result<()> { + fn enabled_config_level_1() { let actual = ModuleRenderer::new("shlvl") .config(toml::toml! { [shlvl] @@ -130,11 +126,10 @@ mod tests { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn lower_threshold() -> io::Result<()> { + fn lower_threshold() { let actual = ModuleRenderer::new("shlvl") .config(toml::toml! { [shlvl] @@ -146,11 +141,10 @@ mod tests { let expected = Some(format!("{} ", style().paint("↕️ 1"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn higher_threshold() -> io::Result<()> { + fn higher_threshold() { let actual = ModuleRenderer::new("shlvl") .config(toml::toml! { [shlvl] @@ -162,11 +156,10 @@ mod tests { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn custom_style() -> io::Result<()> { + fn custom_style() { let actual = ModuleRenderer::new("shlvl") .config(toml::toml! { [shlvl] @@ -178,11 +171,10 @@ mod tests { let expected = Some(format!("{} ", Color::Red.underline().paint("↕️ 2"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn custom_symbol() -> io::Result<()> { + fn custom_symbol() { let actual = ModuleRenderer::new("shlvl") .config(toml::toml! { [shlvl] @@ -194,11 +186,10 @@ mod tests { let expected = Some(format!("{} ", style().paint("shlvl is 2"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn formatting() -> io::Result<()> { + fn formatting() { let actual = ModuleRenderer::new("shlvl") .config(toml::toml! { [shlvl] @@ -210,11 +201,10 @@ mod tests { let expected = Some(format!("↕️ going down {} GOING UP ", style().paint("2"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn repeat() -> io::Result<()> { + fn repeat() { let actual = ModuleRenderer::new("shlvl") .config(toml::toml! { [shlvl] @@ -228,6 +218,5 @@ mod tests { let expected = Some(format!("{} ", style().paint("~~~>"))); assert_eq!(expected, actual); - Ok(()) } } diff --git a/src/modules/singularity.rs b/src/modules/singularity.rs index c408ddb2..a6ec73b8 100644 --- a/src/modules/singularity.rs +++ b/src/modules/singularity.rs @@ -45,18 +45,16 @@ pub fn module<'a>(context: &'a Context) -> Option> { mod tests { use crate::test::ModuleRenderer; use ansi_term::Color; - use std::io; #[test] - fn no_env_set() -> io::Result<()> { + fn no_env_set() { let actual = ModuleRenderer::new("singularity").collect(); let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn env_set() -> io::Result<()> { + fn env_set() { let actual = ModuleRenderer::new("singularity") .env("SINGULARITY_NAME", "centos.img") .collect(); @@ -67,6 +65,5 @@ mod tests { )); assert_eq!(expected, actual); - Ok(()) } } diff --git a/src/modules/status.rs b/src/modules/status.rs index 024f2ad9..609e1bb6 100644 --- a/src/modules/status.rs +++ b/src/modules/status.rs @@ -147,12 +147,11 @@ fn status_signal_name(signal: SignalNumber) -> Option<&'static str> { #[cfg(test)] mod tests { use ansi_term::Color; - use std::io; use crate::test::ModuleRenderer; #[test] - fn success_status() -> io::Result<()> { + fn success_status() { let expected = None; // Status code 0 @@ -173,21 +172,18 @@ mod tests { }) .collect(); assert_eq!(expected, actual); - - Ok(()) } #[test] - fn not_enabled() -> io::Result<()> { + fn not_enabled() { let expected = None; let actual = ModuleRenderer::new("status").status(1).collect(); assert_eq!(expected, actual); - Ok(()) } #[test] - fn failure_status() -> io::Result<()> { + fn failure_status() { let exit_values = [1, 2, 130]; for status in exit_values.iter() { @@ -205,12 +201,10 @@ mod tests { .collect(); assert_eq!(expected, actual); } - - Ok(()) } #[test] - fn signal_name() -> io::Result<()> { + fn signal_name() { let exit_values = [1, 2, 126, 127, 130, 101]; let exit_values_name = [ Some("ERROR"), @@ -233,12 +227,10 @@ mod tests { .collect(); assert_eq!(expected, actual); } - - Ok(()) } #[test] - fn exit_code_name_no_signal() -> io::Result<()> { + fn exit_code_name_no_signal() { let exit_values = [1, 2, 126, 127, 130, 101, 132]; let exit_values_name = [ Some("ERROR"), @@ -263,12 +255,10 @@ mod tests { .collect(); assert_eq!(expected, actual); } - - Ok(()) } #[test] - fn maybe_exit_code_number() -> io::Result<()> { + fn maybe_exit_code_number() { let exit_values = [1, 2, 126, 127, 130, 101, 6, -3]; let exit_values_name = [ None, @@ -293,12 +283,10 @@ mod tests { .collect(); assert_eq!(expected, actual); } - - Ok(()) } #[test] - fn special_symbols() -> io::Result<()> { + fn special_symbols() { let exit_values = [1, 126, 127, 130, 131]; let exit_values_name = ["🔴", "🚫", "🔍", "🧱", "⚡"]; @@ -321,12 +309,10 @@ mod tests { .collect(); assert_eq!(expected, actual); } - - Ok(()) } #[test] - fn special_symbols_no_signals() -> io::Result<()> { + fn special_symbols_no_signals() { let exit_values = [1, 126, 127, 130, 131]; let exit_values_name = ["🔴", "🚫", "🔍", "🔴", "🔴"]; @@ -349,7 +335,5 @@ mod tests { .collect(); assert_eq!(expected, actual); } - - Ok(()) } } diff --git a/src/modules/time.rs b/src/modules/time.rs index 4bd0db5c..cfdff841 100644 --- a/src/modules/time.rs +++ b/src/modules/time.rs @@ -155,7 +155,6 @@ mod tests { use super::*; use crate::test::ModuleRenderer; use chrono::offset::TimeZone; - use std::io; const FMT_12: &str = "%r"; const FMT_24: &str = "%T"; @@ -470,7 +469,7 @@ mod tests { } #[test] - fn config_enabled() -> io::Result<()> { + fn config_enabled() { let actual = ModuleRenderer::new("time") .config(toml::toml! { [time] @@ -480,20 +479,18 @@ mod tests { // We can't test what it actually is...but we can assert that it is something assert!(actual.is_some()); - Ok(()) } #[test] - fn config_blank() -> io::Result<()> { + fn config_blank() { let actual = ModuleRenderer::new("time").collect(); let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn config_check_prefix_and_suffix() -> io::Result<()> { + fn config_check_prefix_and_suffix() { let actual = ModuleRenderer::new("time") .config(toml::toml! { [time] @@ -512,6 +509,5 @@ mod tests { assert!(actual.starts_with(&col_prefix)); assert!(actual.ends_with(&col_suffix)); - Ok(()) } } diff --git a/src/modules/username.rs b/src/modules/username.rs index 2812e661..d2ea8f25 100644 --- a/src/modules/username.rs +++ b/src/modules/username.rs @@ -79,33 +79,30 @@ fn is_ssh_connection(context: &Context) -> bool { mod tests { use crate::test::ModuleRenderer; use ansi_term::Color; - use std::io; // TODO: Add tests for if root user (UID == 0) // Requires mocking #[test] - fn no_env_variables() -> io::Result<()> { + fn no_env_variables() { let actual = ModuleRenderer::new("username").collect(); let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn no_logname_env_variable() -> io::Result<()> { + fn no_logname_env_variable() { let actual = ModuleRenderer::new("username") .env(super::USERNAME_ENV_VAR, "astronaut") .collect(); let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn logname_equals_user() -> io::Result<()> { + fn logname_equals_user() { let actual = ModuleRenderer::new("username") .env("LOGNAME", "astronaut") .env(super::USERNAME_ENV_VAR, "astronaut") @@ -113,11 +110,10 @@ mod tests { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn ssh_wo_username() -> io::Result<()> { + fn ssh_wo_username() { // SSH connection w/o username let actual = ModuleRenderer::new("username") .env("SSH_CONNECTION", "192.168.223.17 36673 192.168.223.229 22") @@ -125,11 +121,10 @@ mod tests { let expected = None; assert_eq!(expected, actual); - Ok(()) } #[test] - fn current_user_not_logname() -> io::Result<()> { + fn current_user_not_logname() { let actual = ModuleRenderer::new("username") .env("LOGNAME", "astronaut") .env(super::USERNAME_ENV_VAR, "cosmonaut") @@ -137,11 +132,10 @@ mod tests { let expected = Some(format!("{} in ", Color::Yellow.bold().paint("cosmonaut"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn ssh_connection() -> io::Result<()> { + fn ssh_connection() { let actual = ModuleRenderer::new("username") .env(super::USERNAME_ENV_VAR, "astronaut") .env("SSH_CONNECTION", "192.168.223.17 36673 192.168.223.229 22") @@ -149,11 +143,10 @@ mod tests { let expected = Some(format!("{} in ", Color::Yellow.bold().paint("astronaut"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn ssh_connection_tty() -> io::Result<()> { + fn ssh_connection_tty() { let actual = ModuleRenderer::new("username") .env(super::USERNAME_ENV_VAR, "astronaut") .env("SSH_TTY", "/dev/pts/0") @@ -161,11 +154,10 @@ mod tests { let expected = Some(format!("{} in ", Color::Yellow.bold().paint("astronaut"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn ssh_connection_client() -> io::Result<()> { + fn ssh_connection_client() { let actual = ModuleRenderer::new("username") .env(super::USERNAME_ENV_VAR, "astronaut") .env("SSH_CLIENT", "192.168.0.101 39323 22") @@ -173,11 +165,10 @@ mod tests { let expected = Some(format!("{} in ", Color::Yellow.bold().paint("astronaut"))); assert_eq!(expected, actual); - Ok(()) } #[test] - fn show_always() -> io::Result<()> { + fn show_always() { let actual = ModuleRenderer::new("username") .env(super::USERNAME_ENV_VAR, "astronaut") .config(toml::toml! { @@ -188,6 +179,5 @@ mod tests { let expected = Some(format!("{} in ", Color::Yellow.bold().paint("astronaut"))); assert_eq!(expected, actual); - Ok(()) } }