Skip to main content

wfe_core/primitives/
end_step.rs

1use async_trait::async_trait;
2
3use crate::models::ExecutionResult;
4use crate::traits::step::{StepBody, StepExecutionContext};
5
6/// A no-op marker step indicating the end of a workflow branch.
7#[derive(Default)]
8pub struct EndStep;
9
10#[async_trait]
11impl StepBody for EndStep {
12    async fn run(&mut self, _context: &StepExecutionContext<'_>) -> crate::Result<ExecutionResult> {
13        Ok(ExecutionResult::next())
14    }
15}
16
17#[cfg(test)]
18mod tests {
19    use super::*;
20    use crate::models::ExecutionPointer;
21    use crate::primitives::test_helpers::*;
22
23    #[tokio::test]
24    async fn always_returns_next() {
25        let mut step = EndStep;
26        let pointer = ExecutionPointer::new(0);
27        let wf_step = default_step();
28        let workflow = default_workflow();
29        let ctx = make_context(&pointer, &wf_step, &workflow);
30
31        let result = step.run(&ctx).await.unwrap();
32        assert!(result.proceed);
33        assert!(result.outcome_value.is_none());
34        assert!(result.persistence_data.is_none());
35    }
36}