Skip to main content

harmont_cloud/
models.rs

1//! Ergonomic re-exports of generated model types plus small helpers.
2
3pub use harmont_cloud_raw::types::{Build, Job, CreateBuildRequest, CreateRepoBuildRequest};
4
5/// Whether a build state is terminal (no further transitions).
6pub fn build_is_terminal(state: &str) -> bool {
7    matches!(state, "passed" | "failed" | "canceled")
8}
9
10/// Whether a job state is terminal.
11pub fn job_is_terminal(state: &str) -> bool {
12    matches!(state, "passed" | "failed" | "skipped" | "canceled" | "timed_out")
13}
14
15#[cfg(test)]
16mod tests {
17    use super::*;
18
19    #[test]
20    fn terminal_build_states() {
21        assert!(build_is_terminal("passed"));
22        assert!(!build_is_terminal("running"));
23    }
24
25    #[test]
26    fn terminal_job_states() {
27        assert!(job_is_terminal("timed_out"));
28        assert!(!job_is_terminal("running"));
29    }
30}