Skip to content

Commit

Permalink
More testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaander committed Aug 13, 2024
1 parent 1807bb6 commit 020f837
Showing 1 changed file with 91 additions and 3 deletions.
94 changes: 91 additions & 3 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ name = "two"
command = "touch workspace/{directory}/two"
products = ["two"]
previous_actions = ["one"]
[[action]]
name = "three"
command = "touch workspace/{directory}/three"
products = ["three"]
[[action.group.include]]
condition = ["/v", "<", 0]
"#,
)?;

Expand Down Expand Up @@ -141,7 +148,8 @@ fn status() -> Result<(), Box<dyn std::error::Error>> {
.assert()
.success()
.stdout(predicate::str::is_match("(?m)^one +0 +0 +10 +0")?)
.stdout(predicate::str::is_match("(?m)^two +0 +0 +0 +10")?);
.stdout(predicate::str::is_match("(?m)^two +0 +0 +0 +10")?)
.stdout(predicate::str::is_match("(?m)^three +0 +0 +0 +0")?.not());

Ok(())
}
Expand All @@ -163,7 +171,8 @@ fn status_waiting() -> Result<(), Box<dyn std::error::Error>> {
.assert()
.success()
.stdout(predicate::str::is_match("(?m)^one +0 +0 +10 +0")?.not())
.stdout(predicate::str::is_match("(?m)^two +0 +0 +0 +10")?);
.stdout(predicate::str::is_match("(?m)^two +0 +0 +0 +10")?)
.stdout(predicate::str::is_match("(?m)^three +0 +0 +0 +0")?.not());

Ok(())
}
Expand All @@ -185,7 +194,86 @@ fn status_eligible() -> Result<(), Box<dyn std::error::Error>> {
.assert()
.success()
.stdout(predicate::str::is_match("(?m)^one +0 +0 +10 +0")?)
.stdout(predicate::str::is_match("(?m)^two +0 +0 +0 +10")?.not());
.stdout(predicate::str::is_match("(?m)^two +0 +0 +0 +10")?.not())
.stdout(predicate::str::is_match("(?m)^three +0 +0 +0 +0")?.not());

Ok(())
}

#[test]
#[parallel]
fn status_submitted() -> Result<(), Box<dyn std::error::Error>> {
let temp = TempDir::new()?;
let _ = setup_sample_workflow(&temp, 10);

Command::cargo_bin("row")?
.args(["show", "status"])
.args(["--cluster", "none"])
.args(["--submitted"])
.current_dir(temp.path())
.env_remove("ROW_COLOR")
.env_remove("CLICOLOR")
.env("ROW_HOME", "/not/a/path")
.assert()
.success()
.stdout(predicate::str::is_match("(?m)^one +0 +0 +10 +0")?.not())
.stdout(predicate::str::is_match("(?m)^two +0 +0 +0 +10")?.not())
.stdout(predicate::str::is_match("(?m)^three +0 +0 +0 +0")?.not());

Ok(())
}

#[test]
#[parallel]
fn status_all() -> Result<(), Box<dyn std::error::Error>> {
let temp = TempDir::new()?;
let _ = setup_sample_workflow(&temp, 10);

Command::cargo_bin("row")?
.args(["show", "status"])
.args(["--cluster", "none"])
.args(["--all"])
.current_dir(temp.path())
.env_remove("ROW_COLOR")
.env_remove("CLICOLOR")
.env("ROW_HOME", "/not/a/path")
.assert()
.success()
.stdout(predicate::str::is_match("(?m)^one +0 +0 +10 +0")?)
.stdout(predicate::str::is_match("(?m)^two +0 +0 +0 +10")?)
.stdout(predicate::str::is_match("(?m)^three +0 +0 +0 +0")?);

Ok(())
}

#[test]
#[parallel]
fn status_completed() -> Result<(), Box<dyn std::error::Error>> {
let temp = TempDir::new()?;
let _ = setup_sample_workflow(&temp, 10);

Command::cargo_bin("row")?
.arg("submit")
.args(["--cluster", "none"])
.current_dir(temp.path())
.env_remove("ROW_COLOR")
.env_remove("CLICOLOR")
.env("ROW_HOME", "/not/a/path")
.assert()
.success();

Command::cargo_bin("row")?
.args(["show", "status"])
.args(["--cluster", "none"])
.args(["--completed"])
.current_dir(temp.path())
.env_remove("ROW_COLOR")
.env_remove("CLICOLOR")
.env("ROW_HOME", "/not/a/path")
.assert()
.success()
.stdout(predicate::str::is_match("(?m)^one +10 +0 +0 +0")?)
.stdout(predicate::str::is_match("(?m)^two +0 +0 +10 +0")?.not());

Ok(())
}
Expand Down

0 comments on commit 020f837

Please sign in to comment.