Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
fix: "cibtool run list" shows ids without loading run info
Lars Wirzenius committed 1 year ago
commit 900a457157da42eedcd5f7ebab48413a4406e27a
parent 756d7ac
4 files changed +24 -8
modified ci-broker.md
@@ -434,7 +434,7 @@ when I run cibtool --db ci-broker.db event list
then stdout is empty

when I run cibtool --db ci-broker.db run list
-
then stdout has 2 lines containing "xyzzy"
+
then stdout has 2 lines
~~~


modified ci-broker.yaml
@@ -25,6 +25,11 @@
    rust:
      function: stdout_has_one_line

+
- then: "stdout has {n:uint} lines"
+
  impl:
+
    rust:
+
      function: stdout_has_n_lines
+

- then: "stdout has {n:uint} lines containing \"{text:text}\""
  impl:
    rust:
modified src/bin/cibtoolcmd/run.rs
@@ -217,18 +217,14 @@ impl Leaf for ListRuns {
    fn run(&self, args: &Args) -> Result<(), CibToolError> {
        let db = args.open_db()?;

-
        let runs = if let Some(wanted) = &self.adapter_run_id {
-
            db.find_runs(wanted)?
-
        } else {
-
            db.get_all_runs()?
-
        };
-

        if self.json {
+
            let runs = db.get_all_runs()?;
            println!(
                "{}",
                serde_json::to_string_pretty(&runs).map_err(CibToolError::RunToJson)?
            );
-
        } else {
+
        } else if let Some(wanted) = &self.adapter_run_id {
+
            let runs = db.find_runs(wanted)?;
            for run in runs {
                println!(
                    "{} {}",
@@ -238,6 +234,11 @@ impl Leaf for ListRuns {
                        .unwrap_or("unknown".into())
                );
            }
+
        } else {
+
            let run_ids = db.list_runs()?;
+
            for run_id in run_ids {
+
                println!("{}", run_id);
+
            }
        }

        Ok(())
modified src/subplot.rs
@@ -398,6 +398,16 @@ fn stdout_has_one_line(runcmd: &Runcmd) {
#[step]
#[context(SubplotContext)]
#[context(Runcmd)]
+
fn stdout_has_n_lines(runcmd: &Runcmd, n: usize) {
+
    let linecount = runcmd.stdout_as_string().lines().count();
+
    if linecount != n {
+
        throw!(format!("stdout had {linecount} lines, expected {n}"));
+
    }
+
}
+

+
#[step]
+
#[context(SubplotContext)]
+
#[context(Runcmd)]
fn stdout_has_n_lines_containing(runcmd: &Runcmd, n: usize, text: &str) {
    let linecount = runcmd
        .stdout_as_string()