huskies: merge 857
This commit is contained in:
@@ -406,4 +406,136 @@ fn transition_error_display() {
|
||||
assert_eq!(err.to_string(), "invalid transition: Backlog + Accepted");
|
||||
}
|
||||
|
||||
// ── Upcoming / Triage ──────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn triage_upcoming_to_backlog() {
|
||||
let s = Stage::Upcoming;
|
||||
let s = transition(s, PipelineEvent::Triage).unwrap();
|
||||
assert!(matches!(s, Stage::Backlog));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cannot_triage_from_backlog() {
|
||||
let result = transition(Stage::Backlog, PipelineEvent::Triage);
|
||||
assert!(matches!(
|
||||
result,
|
||||
Err(TransitionError::InvalidTransition { .. })
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn abandon_from_upcoming() {
|
||||
let result = transition(Stage::Upcoming, PipelineEvent::Abandon).unwrap();
|
||||
assert!(matches!(
|
||||
result,
|
||||
Stage::Archived {
|
||||
reason: ArchiveReason::Abandoned,
|
||||
..
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn supersede_from_upcoming() {
|
||||
let result = transition(
|
||||
Stage::Upcoming,
|
||||
PipelineEvent::Supersede {
|
||||
by: sid("999_story_new"),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
assert!(matches!(
|
||||
result,
|
||||
Stage::Archived {
|
||||
reason: ArchiveReason::Superseded { .. },
|
||||
..
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cannot_deps_met_from_upcoming() {
|
||||
let result = transition(Stage::Upcoming, PipelineEvent::DepsMet);
|
||||
assert!(matches!(
|
||||
result,
|
||||
Err(TransitionError::InvalidTransition { .. })
|
||||
));
|
||||
}
|
||||
|
||||
// ── Reject ─────────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn reject_from_active_stages() {
|
||||
for s in [Stage::Backlog, Stage::Coding, Stage::Qa] {
|
||||
let result = transition(
|
||||
s.clone(),
|
||||
PipelineEvent::Reject {
|
||||
reason: "not needed".into(),
|
||||
},
|
||||
);
|
||||
assert!(matches!(
|
||||
result,
|
||||
Ok(Stage::Archived {
|
||||
reason: ArchiveReason::Rejected { .. },
|
||||
..
|
||||
})
|
||||
));
|
||||
}
|
||||
|
||||
let m = Stage::Merge {
|
||||
feature_branch: fb("f"),
|
||||
commits_ahead: nz(1),
|
||||
};
|
||||
let result = transition(
|
||||
m,
|
||||
PipelineEvent::Reject {
|
||||
reason: "not needed".into(),
|
||||
},
|
||||
);
|
||||
assert!(matches!(
|
||||
result,
|
||||
Ok(Stage::Archived {
|
||||
reason: ArchiveReason::Rejected { .. },
|
||||
..
|
||||
})
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cannot_reject_from_done() {
|
||||
let s = Stage::Done {
|
||||
merged_at: chrono::Utc::now(),
|
||||
merge_commit: sha("abc"),
|
||||
};
|
||||
let result = transition(
|
||||
s,
|
||||
PipelineEvent::Reject {
|
||||
reason: "too late".into(),
|
||||
},
|
||||
);
|
||||
assert!(matches!(
|
||||
result,
|
||||
Err(TransitionError::InvalidTransition { .. })
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cannot_reject_from_archived() {
|
||||
let s = Stage::Archived {
|
||||
archived_at: chrono::Utc::now(),
|
||||
reason: ArchiveReason::Completed,
|
||||
};
|
||||
let result = transition(
|
||||
s,
|
||||
PipelineEvent::Reject {
|
||||
reason: "already done".into(),
|
||||
},
|
||||
);
|
||||
assert!(matches!(
|
||||
result,
|
||||
Err(TransitionError::InvalidTransition { .. })
|
||||
));
|
||||
}
|
||||
|
||||
// ── ProjectionError Display ─────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user