Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix]: fix for regression regarding delimiters for show summary #494

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
}
}