Skip to content

Commit

Permalink
Add check-all subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Notgnoshi committed Jul 15, 2024
1 parent ebdc64d commit 8c6a3ad
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ pub fn check(args: &CheckArgs) -> eyre::Result<()> {
process_achievements(achievements)
}

pub fn check_all(_args: &CheckAllArgs, _config: &Config, _data_dir: &Path) -> eyre::Result<()> {
eyre::bail!("check-all not implemented");
pub fn check_all(_args: &CheckAllArgs, config: &Config, _data_dir: &Path) -> eyre::Result<()> {
for config in config.repositories.values() {
let repo = find_local_repository(&config.path)?;
let reference = config
.branch
.clone()
.unwrap_or_else(|| String::from("HEAD"));
let achievements = grant(&reference, &repo)?;
process_achievements(achievements)?;
}

Ok(())
}

/// A common achievement sink that both check and check_all can use
Expand Down
26 changes: 26 additions & 0 deletions tests/check_all.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
mod common;

use common::CommandExt;
use predicates::prelude::*;
use predicates::str;

#[test]
fn add_self_and_then_check_all() {
let self_dir = format!("file://{}", env!("CARGO_MANIFEST_DIR"));
let (mut cmd, temp) = common::herostratus(None);
cmd.arg("add").arg(self_dir).arg("main");

let output = cmd.captured_output().unwrap();
assert!(output.status.success());

let (mut cmd, _) = common::herostratus(Some(temp.as_ref().unwrap().path()));
cmd.arg("check-all");
let output = cmd.captured_output().unwrap();
assert!(output.status.success());

// who knows how many achievements 'main' will have?
let assertion =
str::contains("Finalizing rules ...").and(str::contains("achievements after processing"));
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(assertion.eval(&stderr));
}

0 comments on commit 8c6a3ad

Please sign in to comment.