Skip to main content

anza_xtask/buildkite/
step.rs

1use {
2    super::{CommandStep, GroupStep, TriggerStep, WaitStep},
3    serde::Serialize,
4};
5
6#[derive(Debug, Serialize, PartialEq)]
7#[serde(untagged)]
8pub enum Step {
9    Command(CommandStep),
10    Wait(WaitStep),
11    Group(GroupStep),
12    Trigger(TriggerStep),
13}
14
15#[cfg(test)]
16mod tests {
17    use {
18        super::*,
19        crate::buildkite::{test_utils::assert_serialized_json, CommandStep},
20    };
21
22    #[test]
23    fn test_step_command_variant_serialize_json() {
24        assert_serialized_json(
25            &Step::Command(CommandStep {
26                name: String::from("test with command"),
27                command: String::from("echo hello"),
28                ..Default::default()
29            }),
30            r#"{
31                "name": "test with command",
32                "command": "echo hello"
33            }"#,
34        );
35    }
36
37    #[test]
38    fn test_step_wait_variant_serialize_json() {
39        assert_serialized_json(
40            &Step::Wait(WaitStep {}),
41            r#"{
42                "wait": "~"
43            }"#,
44        );
45    }
46}