This commit is contained in:
Timmy
2026-04-10 01:04:09 +01:00
parent 0de9200d48
commit 962e3d4e7d
+20 -21
View File
@@ -223,10 +223,7 @@ pub enum PipelineEvent {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum TransitionError { pub enum TransitionError {
InvalidTransition { InvalidTransition { from_stage: String, event: String },
from_stage: String,
event: String,
},
} }
impl fmt::Display for TransitionError { impl fmt::Display for TransitionError {
@@ -263,11 +260,23 @@ pub fn transition(state: Stage, event: PipelineEvent) -> Result<Stage, Transitio
// ── Forward path ──────────────────────────────────────────────── // ── Forward path ────────────────────────────────────────────────
(Backlog, DepsMet) => Ok(Coding), (Backlog, DepsMet) => Ok(Coding),
(Coding, GatesStarted) => Ok(Qa), (Coding, GatesStarted) => Ok(Qa),
(Coding, QaSkipped { feature_branch, commits_ahead }) => Ok(Merge { (
Coding,
QaSkipped {
feature_branch,
commits_ahead,
},
) => Ok(Merge {
feature_branch, feature_branch,
commits_ahead, commits_ahead,
}), }),
(Qa, GatesPassed { feature_branch, commits_ahead }) => Ok(Merge { (
Qa,
GatesPassed {
feature_branch,
commits_ahead,
},
) => Ok(Merge {
feature_branch, feature_branch,
commits_ahead, commits_ahead,
}), }),
@@ -507,10 +516,7 @@ pub enum ProjectionError {
/// A required field is missing from the CRDT data. /// A required field is missing from the CRDT data.
MissingField(&'static str), MissingField(&'static str),
/// A field has an invalid value. /// A field has an invalid value.
InvalidField { InvalidField { field: &'static str, detail: String },
field: &'static str,
detail: String,
},
} }
impl fmt::Display for ProjectionError { impl fmt::Display for ProjectionError {
@@ -575,8 +581,7 @@ fn project_stage(view: &PipelineItemView) -> Result<Stage, ProjectionError> {
// at least one commit). // at least one commit).
Ok(Stage::Merge { Ok(Stage::Merge {
feature_branch: BranchName(branch), feature_branch: BranchName(branch),
commits_ahead: NonZeroU32::new(1) commits_ahead: NonZeroU32::new(1).expect("1 is non-zero"),
.expect("1 is non-zero"),
}) })
} }
"5_done" => { "5_done" => {
@@ -1094,10 +1099,7 @@ mod tests {
assert!(matches!(e, ExecutionState::Running { .. })); assert!(matches!(e, ExecutionState::Running { .. }));
let e = execution_transition(e, ExecutionEvent::Exited { exit_code: 0 }).unwrap(); let e = execution_transition(e, ExecutionEvent::Exited { exit_code: 0 }).unwrap();
assert!(matches!( assert!(matches!(e, ExecutionState::Completed { exit_code: 0, .. }));
e,
ExecutionState::Completed { exit_code: 0, .. }
));
} }
#[test] #[test]
@@ -1313,8 +1315,8 @@ mod tests {
#[test] #[test]
fn event_bus_fires_to_all_subscribers() { fn event_bus_fires_to_all_subscribers() {
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::{AtomicU32, Ordering};
struct CountingSub(Arc<AtomicU32>); struct CountingSub(Arc<AtomicU32>);
impl TransitionSubscriber for CountingSub { impl TransitionSubscriber for CountingSub {
@@ -1368,10 +1370,7 @@ mod tests {
from_stage: "Backlog".into(), from_stage: "Backlog".into(),
event: "Accepted".into(), event: "Accepted".into(),
}; };
assert_eq!( assert_eq!(err.to_string(), "invalid transition: Backlog + Accepted");
err.to_string(),
"invalid transition: Backlog + Accepted"
);
} }
// ── ProjectionError Display ───────────────────────────────────────── // ── ProjectionError Display ─────────────────────────────────────────