Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
flawiddsouza committed Nov 9, 2024
1 parent d888134 commit 03bec98
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let deploy_file = matches.get_one::<String>("deploy_file").unwrap();
let extra_vars = matches.get_one::<String>("extra_vars").map(|s| s.as_str());
let default_server_file = "servers.yml".to_string();
let server_file = matches.get_one::<String>("server_file").unwrap_or(&default_server_file);
let server_file = matches
.get_one::<String>("server_file")
.unwrap_or(&default_server_file);

let server_config: ServerConfig = read_yaml(server_file)?;
let deployment_docs: Vec<Vec<Deployment>> = read_yaml_multi(deploy_file)?;
Expand Down
45 changes: 40 additions & 5 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@ impl Drop for DockerGuard {

fn start_docker_container() {
let start_output = Command::new("docker")
.args(&["run", "-d", "--rm", "-p", "2222:2222", "--name", "ssh_test_server", "-e", "USER_NAME=root", "-e", "USER_PASSWD=password", "forumi0721/alpine-sshd:x64"])
.args(&[
"run",
"-d",
"--rm",
"-p",
"2222:2222",
"--name",
"ssh_test_server",
"-e",
"USER_NAME=root",
"-e",
"USER_PASSWD=password",
"forumi0721/alpine-sshd:x64",
])
.output()
.expect("Failed to start Docker container");

Expand All @@ -29,7 +42,16 @@ fn stop_docker_container() {

fn run_test(yml_file: &str, should_fail: bool, extra_vars: &str, inventory_file: &str) {
let output = Command::new("cargo")
.args(&["run", "--quiet", "--", yml_file, "--extra-vars", extra_vars, "--inventory", inventory_file])
.args(&[
"run",
"--quiet",
"--",
yml_file,
"--extra-vars",
extra_vars,
"--inventory",
inventory_file,
])
.output()
.expect("Failed to execute command");

Expand Down Expand Up @@ -59,7 +81,12 @@ fn setup() -> DockerGuard {

fn run_tests_for_both_inventories(yml_file: &str, should_fail: bool, extra_vars: &str) {
run_test(yml_file, should_fail, extra_vars, "tests/servers/local.yml");
run_test(yml_file, should_fail, extra_vars, "tests/servers/remote.yml");
run_test(
yml_file,
should_fail,
extra_vars,
"tests/servers/remote.yml",
);
}

#[test]
Expand Down Expand Up @@ -166,8 +193,16 @@ fn invalid_json_error() {
fn extra_vars() {
setup();
run_tests_for_both_inventories("test-ymls/extra-vars.yml", false, "cat=1 bat=2");
run_tests_for_both_inventories("test-ymls/extra-vars.yml", false, "{ \"cat\": 1, \"bat\": 2 }");
run_tests_for_both_inventories("test-ymls/extra-vars.yml", false, "@test-ymls/extra-vars.vars.yml");
run_tests_for_both_inventories(
"test-ymls/extra-vars.yml",
false,
"{ \"cat\": 1, \"bat\": 2 }",
);
run_tests_for_both_inventories(
"test-ymls/extra-vars.yml",
false,
"@test-ymls/extra-vars.vars.yml",
);
}

#[test]
Expand Down

0 comments on commit 03bec98

Please sign in to comment.