Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(clippy): fix new lints #2297

Merged
merged 1 commit into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 14 additions & 28 deletions src/modules/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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! {
Expand All @@ -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")
Expand All @@ -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();
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -218,7 +212,6 @@ mod tests {
));

assert_eq!(expected, actual);
Ok(())
}

#[test]
Expand Down Expand Up @@ -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")
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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! {
Expand All @@ -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]
Expand All @@ -389,6 +376,5 @@ region = us-east-2
let expected = None;

assert_eq!(expected, actual);
Ok(())
}
}
21 changes: 5 additions & 16 deletions src/modules/character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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];
Expand All @@ -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("➜")));

Expand Down Expand Up @@ -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("❯")));
Expand Down Expand Up @@ -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("❯")));
Expand Down Expand Up @@ -203,7 +194,5 @@ mod test {
.keymap("visual")
.collect();
assert_eq!(expected_other, actual);

Ok(())
}
}
19 changes: 6 additions & 13 deletions src/modules/cmd_duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ mod tests {
use super::*;
use crate::test::ModuleRenderer;
use ansi_term::Color;
use std::io;

#[test]
fn test_500ms() {
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -230,6 +224,5 @@ mod tests {

let expected = Some(format!("underwent {} ", Color::Yellow.bold().paint("5s")));
assert_eq!(expected, actual);
Ok(())
}
}
Loading