Skip to content

Commit f0cd94d

Browse files
committed
test: a finished matter and a behind refusal alone are pinned
Two reasons §FS-005-dispatch.27.1 states had no test. `why_not_offered` on a merged pull request now has to say the matter is finished and name no selector field, though its recipe's `kinds` would also have refused it. `Recipe::withheld` against a `behind: true` selector on a branch level with main has to keep the `behind` refusal, which the offers reading drops and a recipe named for the matter names.
1 parent 04c29d9 commit f0cd94d

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

‎src/work/mod_tests.rs‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6793,6 +6793,35 @@ fn issue_191_a_plain_run_passes_a_private_plan_over() {
67936793
assert!(named[0].private.is_none());
67946794
}
67956795

6796+
/// A recipe named for a finished matter is refused because the matter is
6797+
/// finished, not for a selector field that would also have refused it
6798+
/// (§FS-005-dispatch.27.1).
6799+
#[test]
6800+
fn a_recipe_named_for_a_finished_matter_says_the_matter_is_finished() {
6801+
let tmp = tempfile::tempdir().unwrap();
6802+
let mut dispatcher = issue_43_dispatcher(tmp.path(), empty_ledger());
6803+
dispatcher.global.recipes = vec![serde_json::from_value(serde_json::json!({
6804+
"id": "issue-work", "description": "work the issue", "brief": "Work {title}.",
6805+
"needs_checkout": false, "when": { "kinds": ["issue"] }
6806+
}))
6807+
.unwrap()];
6808+
let mut merged = issue_43_item();
6809+
merged.kind = crate::feed::model::ItemKind::Pr;
6810+
merged.state = Some("merged".to_string());
6811+
assert!(merged.is_finished());
6812+
6813+
let says = dispatcher.why_not_offered(&merged, "issue-work");
6814+
assert!(
6815+
says.contains("issue-work") && says.contains(&merged.id),
6816+
"{says}"
6817+
);
6818+
assert!(says.contains("finished"), "{says}");
6819+
assert!(
6820+
!says.contains("selector") && !says.contains("kind"),
6821+
"a selector field was named for a finished matter: {says}"
6822+
);
6823+
}
6824+
67966825
/// A name that is a workflow entry rather than a recipe is pointed at the door
67976826
/// that lays it, not told it is unconfigured (§FS-005-dispatch.27.1).
67986827
#[test]

‎src/work/recipe.rs‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,35 @@ mod tests {
22302230
assert!(!level.matches(&pr, &Facts::default()));
22312231
}
22322232

2233+
/// What withholds a recipe keeps `behind` refusing alone: the offers
2234+
/// reading drops it, and a recipe named for the matter names it
2235+
/// (§FS-005-dispatch.27.1).
2236+
#[test]
2237+
fn a_behind_refusal_alone_is_kept_among_what_withholds_a_recipe() {
2238+
let trailing = serde_json::from_value::<Recipe>(json!({
2239+
"id": "trailing", "description": "replay it", "brief": "Replay {title}.",
2240+
"when": { "behind": true }
2241+
}))
2242+
.unwrap();
2243+
let level = Facts {
2244+
behind: Some(0),
2245+
..Facts::default()
2246+
};
2247+
let refused = trailing.withheld(&item(ItemKind::Pr, None), &level, None);
2248+
assert_eq!(
2249+
refused
2250+
.iter()
2251+
.map(|refusal| refusal.field)
2252+
.collect::<Vec<_>>(),
2253+
["behind"]
2254+
);
2255+
assert!(
2256+
refused[0].reason.contains("level with"),
2257+
"{}",
2258+
refused[0].reason
2259+
);
2260+
}
2261+
22332262
/// The other distance is asked about in the same words, and answered from
22342263
/// the same fold (§FS-004-quick-actions.8). The two are separate
22352264
/// questions: a branch level with main can be well behind its own copy.

0 commit comments

Comments
 (0)