Skip to content

Commit

Permalink
[BugFix]: fix for regression regarding delimiters for show summary (#494
Browse files Browse the repository at this point in the history
)

* [BugFix]: fix for regression regarding delimiters for show summary on validate command

* [Misc]: updating _typos.toml
  • Loading branch information
joshfried-aws committed Apr 12, 2024
1 parent e44fc14 commit 58565f5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ archtype = "archtype"
ure = "ure"
# Don't flag dne as a misspelling
dne = "dne"
# Don't flag kms as mispelling
kms = "kms"
[default.extend-identifiers]
# Ignore ID in evaluate_tests.rs
fooCounterTaskDef49BA9021 = "fooCounterTaskDef49BA9021"

2 changes: 1 addition & 1 deletion guard/src/commands/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub struct Validate {
/// default is single-line-summary
/// if junit is used, `structured` attributed must be set to true
pub(crate) output_format: OutputFormatType,
#[arg(short=SHOW_SUMMARY.1, long, help=SHOW_SUMMARY_HELP, value_enum, default_values_t=vec![ShowSummaryType::Fail])]
#[arg(short=SHOW_SUMMARY.1, long, help=SHOW_SUMMARY_HELP, value_enum, default_values_t=vec![ShowSummaryType::Fail], value_delimiter=',')]
/// Controls if the summary table needs to be displayed. --show-summary fail (default) or --show-summary pass,fail (only show rules that did pass/fail) or --show-summary none (to turn it off) or --show-summary all (to show all the rules that pass, fail or skip)
/// default is failed
/// must be set to none if used together with the structured flag
Expand Down
23 changes: 23 additions & 0 deletions guard/tests/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,4 +782,27 @@ mod validate_tests {
writer
);
}

#[rstest::rstest]
#[case("single-line-summary", vec!["pass", "fail"])]
#[case("single-line-summary", vec!["skip", "fail"])]
#[case("single-line-summary", vec!["skip", "pass"])]
fn test_validate_with_show_summary_combinations(
#[case] output: &str,
#[case] show_summary: Vec<&str>,
) {
let mut reader = Reader::default();
let mut writer = Writer::default();

let status_code = ValidateTestRunner::default()
.rules(vec!["/rules-dir"])
.data(vec![
"/data-dir/s3-public-read-prohibited-template-non-compliant.yaml",
])
.show_summary(show_summary)
.output_format(Option::from(output))
.run(&mut writer, &mut reader);

assert_eq!(StatusCode::VALIDATION_ERROR, status_code);
}
}

0 comments on commit 58565f5

Please sign in to comment.