Skip to content

Commit 9fdbeb5

Browse files
test: fix vacuous and incomplete assertions in fuzzy_schedule and dotnet (#906)
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: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e83cd60 commit 9fdbeb5

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/fuzzy_schedule.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,13 @@ mod tests {
954954
// Validate hour field
955955
let hour: u32 = parts[1].parse().expect("Hour should be a number");
956956
assert!(hour < 24, "Hour should be 0-23");
957+
958+
// Daily schedule must not restrict day-of-month, month, or day-of-week.
959+
// A regression that adds e.g. a day-of-week constraint would silently
960+
// turn a daily schedule into a weekly one.
961+
assert_eq!(parts[2], "*", "Day-of-month should be * for a daily schedule");
962+
assert_eq!(parts[3], "*", "Month should be * for a daily schedule");
963+
assert_eq!(parts[4], "*", "Day-of-week should be * for a daily schedule");
957964
}
958965

959966
#[test]
@@ -991,6 +998,10 @@ mod tests {
991998
let yaml = generate_schedule_yaml("daily", "test/agent", &[]).unwrap();
992999
assert!(yaml.contains("schedules:"));
9931000
assert!(yaml.contains("cron:"));
1001+
// `always: true` is load-bearing — without it ADO only fires the schedule
1002+
// when the target branch has changed since the last run, turning a
1003+
// "run unconditionally on schedule" pipeline into one that silently skips.
1004+
assert!(yaml.contains("always: true"), "schedule YAML must include always: true");
9941005
// No branches filter by default
9951006
assert!(!yaml.contains("branches:"));
9961007
}
@@ -1001,6 +1012,7 @@ mod tests {
10011012
let yaml = generate_schedule_yaml("daily", "test/agent", &branches).unwrap();
10021013
assert!(yaml.contains("schedules:"));
10031014
assert!(yaml.contains("cron:"));
1015+
assert!(yaml.contains("always: true"), "schedule YAML must include always: true");
10041016
assert!(yaml.contains("branches:"));
10051017
assert!(yaml.contains("include:"));
10061018
assert!(yaml.contains("- main"));

src/runtimes/dotnet/extension.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,6 @@ mod tests {
201201
assert!(ext.validate(&ctx_from(&fm)).is_err());
202202
}
203203

204-
#[test]
205-
fn test_validate_global_json_sentinel_skips_injection_check() {
206-
let (fm, _) = parse_markdown(
207-
"---\nname: test\ndescription: test\nruntimes:\n dotnet:\n version: 'global.json'\n---\n",
208-
)
209-
.unwrap();
210-
let dotnet = fm.runtimes.as_ref().unwrap().dotnet.as_ref().unwrap();
211-
let ext = DotnetExtension::new(dotnet.clone());
212-
assert!(ext.validate(&ctx_from(&fm)).is_ok());
213-
}
214-
215204
#[test]
216205
fn test_validate_global_json_conflict_bails() {
217206
let tmp = tempfile::tempdir().unwrap();

0 commit comments

Comments
 (0)