From fd8e445a67e7d0a64ccb0271eadaf603f73bd7d8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 14:15:23 +0000 Subject: [PATCH] test: fix vacuous and incomplete assertions in fuzzy_schedule and dotnet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fuzzy_schedule.rs: - test_cron_format: add assertions that day-of-month, month, and day-of-week fields are '*' for a Daily schedule. Without these, a regression that added a day-of-week or day-of-month constraint would silently turn a daily schedule into a weekly or monthly one. - test_generate_schedule_yaml / test_generate_schedule_yaml_with_branches: add 'assert!(yaml.contains("always: true"))'. The 'always: true' flag is load-bearing — without it ADO only fires the schedule when the target branch has new commits, silently skipping unconditional runs. Removing it from the template would pass the old tests undetected. dotnet/extension.rs: - Remove test_validate_global_json_sentinel_skips_injection_check. The assertion 'is_ok()' is vacuous: 'global.json' contains no injection characters, so validate() returns Ok regardless of whether the sentinel bypass exists. The stronger test_validate_global_json_sentinel_accepted_with_file_present already covers the meaningful scenario (compile_dir contains global.json, sentinel version resolves the conflict). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/fuzzy_schedule.rs | 12 ++++++++++++ src/runtimes/dotnet/extension.rs | 11 ----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/fuzzy_schedule.rs b/src/fuzzy_schedule.rs index fe03a1cc..e1b255d9 100644 --- a/src/fuzzy_schedule.rs +++ b/src/fuzzy_schedule.rs @@ -954,6 +954,13 @@ mod tests { // Validate hour field let hour: u32 = parts[1].parse().expect("Hour should be a number"); assert!(hour < 24, "Hour should be 0-23"); + + // Daily schedule must not restrict day-of-month, month, or day-of-week. + // A regression that adds e.g. a day-of-week constraint would silently + // turn a daily schedule into a weekly one. + assert_eq!(parts[2], "*", "Day-of-month should be * for a daily schedule"); + assert_eq!(parts[3], "*", "Month should be * for a daily schedule"); + assert_eq!(parts[4], "*", "Day-of-week should be * for a daily schedule"); } #[test] @@ -991,6 +998,10 @@ mod tests { let yaml = generate_schedule_yaml("daily", "test/agent", &[]).unwrap(); assert!(yaml.contains("schedules:")); assert!(yaml.contains("cron:")); + // `always: true` is load-bearing — without it ADO only fires the schedule + // when the target branch has changed since the last run, turning a + // "run unconditionally on schedule" pipeline into one that silently skips. + assert!(yaml.contains("always: true"), "schedule YAML must include always: true"); // No branches filter by default assert!(!yaml.contains("branches:")); } @@ -1001,6 +1012,7 @@ mod tests { let yaml = generate_schedule_yaml("daily", "test/agent", &branches).unwrap(); assert!(yaml.contains("schedules:")); assert!(yaml.contains("cron:")); + assert!(yaml.contains("always: true"), "schedule YAML must include always: true"); assert!(yaml.contains("branches:")); assert!(yaml.contains("include:")); assert!(yaml.contains("- main")); diff --git a/src/runtimes/dotnet/extension.rs b/src/runtimes/dotnet/extension.rs index 78fd6389..0c2ea650 100644 --- a/src/runtimes/dotnet/extension.rs +++ b/src/runtimes/dotnet/extension.rs @@ -201,17 +201,6 @@ mod tests { assert!(ext.validate(&ctx_from(&fm)).is_err()); } - #[test] - fn test_validate_global_json_sentinel_skips_injection_check() { - let (fm, _) = parse_markdown( - "---\nname: test\ndescription: test\nruntimes:\n dotnet:\n version: 'global.json'\n---\n", - ) - .unwrap(); - let dotnet = fm.runtimes.as_ref().unwrap().dotnet.as_ref().unwrap(); - let ext = DotnetExtension::new(dotnet.clone()); - assert!(ext.validate(&ctx_from(&fm)).is_ok()); - } - #[test] fn test_validate_global_json_conflict_bails() { let tmp = tempfile::tempdir().unwrap();