swarm: the notification router tells a PR's author when CI on it fails or is cancelled
This commit is contained in:
parent
d4e58f8741
commit
c8eaa93268
1 changed files with 490 additions and 60 deletions
|
|
@ -149,6 +149,17 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
|
||||
/// The built-in flows, in the order the router runs them.
|
||||
const BUILTIN_IDS: [&str; 7] = [
|
||||
"assigned",
|
||||
"unassigned",
|
||||
"closed",
|
||||
"head-classifier",
|
||||
"ci-failed",
|
||||
"ci-cancelled",
|
||||
"ci-cleared",
|
||||
];
|
||||
|
||||
fn ids(f: &Flows) -> Vec<&str> {
|
||||
f.active.iter().map(|f| f.id.as_str()).collect()
|
||||
}
|
||||
|
|
@ -188,28 +199,30 @@ mod tests {
|
|||
#[test]
|
||||
fn with_no_document_the_router_runs_the_builtins() {
|
||||
let mut f = Flows::builtins();
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
assert_eq!(ids(&f), BUILTIN_IDS);
|
||||
f.apply(Read::Absent);
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
assert_eq!(ids(&f), BUILTIN_IDS);
|
||||
// An empty document is the same.
|
||||
f.apply(at(1, doc(&[], &[])));
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
assert_eq!(ids(&f), BUILTIN_IDS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_document_switches_builtins_off_and_adds_custom_flows() {
|
||||
let mut f = Flows::builtins();
|
||||
f.apply(at(1, doc(&["unassigned"], &["triage"])));
|
||||
assert_eq!(ids(&f), ["assigned", "closed", "head-classifier", "triage"]);
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
[
|
||||
"assigned",
|
||||
"closed",
|
||||
"head-classifier",
|
||||
"ci-failed",
|
||||
"ci-cancelled",
|
||||
"ci-cleared",
|
||||
"triage"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -217,7 +230,10 @@ mod tests {
|
|||
let mut f = Flows::builtins();
|
||||
f.apply(at(1, doc(&["closed"], &["triage"])));
|
||||
let before = ids(&f).join(",");
|
||||
assert_eq!(before, "assigned,unassigned,head-classifier,triage");
|
||||
assert_eq!(
|
||||
before,
|
||||
"assigned,unassigned,head-classifier,ci-failed,ci-cancelled,ci-cleared,triage"
|
||||
);
|
||||
for bad in [
|
||||
junk(2, b"not json"),
|
||||
junk(3, br#"{"version":2,"flows":[]}"#),
|
||||
|
|
@ -230,20 +246,14 @@ mod tests {
|
|||
// The next good revision replaces them: the control that the bad
|
||||
// ones were kept out by being bad, not by the loader being stuck.
|
||||
f.apply(at(5, doc(&[], &[])));
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
assert_eq!(ids(&f), BUILTIN_IDS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bad_first_document_is_the_builtins_not_nothing() {
|
||||
let mut f = Flows::builtins();
|
||||
f.apply(junk(1, br#"{"version":9}"#));
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
assert_eq!(ids(&f), BUILTIN_IDS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -251,10 +261,7 @@ mod tests {
|
|||
let mut f = Flows::builtins();
|
||||
f.apply(at(1, doc(&["closed"], &["triage"])));
|
||||
f.apply(Read::Absent);
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
assert_eq!(ids(&f), BUILTIN_IDS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -272,9 +279,6 @@ mod tests {
|
|||
revision: 1,
|
||||
bytes: serde_json::to_vec(&d).unwrap(),
|
||||
});
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
assert_eq!(ids(&f), BUILTIN_IDS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue