Skip to content

Commit

Permalink
Merge pull request #31 from mdpadberg/#30-login-command-broken
Browse files Browse the repository at this point in the history
Fix for broken login command
  • Loading branch information
mdpadberg authored May 1, 2023
2 parents 4fcdf48 + 25d304c commit 4fae83a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub async fn parse() -> Result<()> {
environment_commands,
} => environment::match_environment(&settings, &options, environment_commands),
Subcommands::Login { name } => {
login(&settings, &options, name, &PathBuf::from(&options.mcf_home))
login(&settings, &options, name, &PathBuf::from(&options.mcf_home)).await
}
Subcommands::Exec { names, command, sequential_mode } => {
exec(
Expand Down
14 changes: 7 additions & 7 deletions lib/src/cf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl CFSubCommandsThatRequireSequentialMode {
}
}

pub fn login(
pub async fn login(
settings: &Settings,
options: &Options,
name: &String,
Expand All @@ -40,8 +40,8 @@ pub fn login(
if some.sso {
cf.arg("--sso");
}
let mut child = cf.spawn().expect("Failure in creating child process");
let _ = child.wait();
let child = cf.spawn().expect("Failure in creating child process");
child.wait_with_output().await?;
} else {
bail!(
"could not find {:#?} in environment list {:#?}",
Expand Down Expand Up @@ -295,8 +295,8 @@ mod tests {
.is_symlink());
}

#[test]
fn test_login_could_not_find_environment_in_list() {
#[tokio::test]
async fn test_login_could_not_find_environment_in_list() {
let tempdir: PathBuf = tempdir().unwrap().into_path();
let result = login(
&Settings {
Expand All @@ -313,7 +313,7 @@ mod tests {
},
&String::from("p02"),
&PathBuf::from(""),
);
).await;
assert!(result.is_err());
assert_eq!(result.unwrap_err().to_string(), "could not find \"p02\" in environment list [\n Environment {\n name: \"p01\",\n url: \"url\",\n sso: false,\n skip_ssl_validation: false,\n },\n]");
}
Expand All @@ -336,7 +336,7 @@ mod tests {
},
&String::from("p01"),
&PathBuf::from(""),
);
).await;
assert!(result.is_ok());
}
}

0 comments on commit 4fae83a

Please sign in to comment.