Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
feat! drop the RunResult::Error variant
Lars Wirzenius committed 2 years ago
commit 601abc94d32ad67ee17576256769f2efb7c4efb5
parent 68fd1877e60812e2c6b2cf426f3117f45ae85255
3 files changed +0 -37
modified src/adapter.rs
@@ -247,28 +247,6 @@ echo '{"response":"finished","result":"failure"}'
    }

    #[test]
-
    fn adapter_returns_error() -> TestResult<()> {
-
        const ADAPTER: &str = r#"#!/bin/bash
-
echo '{"response":"triggered","run_id":{"id":"xyzzy"}}'
-
echo '{"response":"finished","result":{"error":"error message\nsecond line"}}'
-
"#;
-

-
        let tmp = tempdir()?;
-
        let bin = tmp.path().join("adapter.sh");
-
        mock_adapter(&bin, ADAPTER)?;
-

-
        let mut run = run();
-
        let mut status = status_page();
-
        Adapter::new(&bin).run(&trigger_request()?, &mut run, &mut status)?;
-
        assert_eq!(
-
            run.result(),
-
            Some(&RunResult::Error("error message\nsecond line".into()))
-
        );
-

-
        Ok(())
-
    }
-

-
    #[test]
    fn adapter_is_killed_before_any_messages() -> TestResult<()> {
        const ADAPTER: &str = r#"#!/bin/bash
kill -9 $BASHPID
modified src/bin/broker-messages.rs
@@ -41,10 +41,4 @@ fn main() {
        "Failure response:\n{}\n",
        serde_json::to_string(&finished).expect("serialize message")
    );
-

-
    let finished = Response::finished(RunResult::Error("error message\nsecond line".into()));
-
    println!(
-
        "Error response:\n{}\n",
-
        serde_json::to_string(&finished).expect("serialize message")
-
    );
}
modified src/msg.rs
@@ -84,9 +84,6 @@ pub enum RunResult {

    /// CI run failed.
    Failure,
-

-
    /// CI run has failed in a way external to the software under test.
-
    Error(String),
}

impl fmt::Display for RunResult {
@@ -94,7 +91,6 @@ impl fmt::Display for RunResult {
        match self {
            Self::Failure => write!(f, "failure"),
            Self::Success => write!(f, "success"),
-
            Self::Error(expl) => write!(f, "error: {}", expl),
        }
    }
}
@@ -555,11 +551,6 @@ impl Response {
        Self::Finished { result }
    }

-
    /// Create a `Response::Error` message.
-
    pub fn error(explanation: &str) -> Self {
-
        Self::finished(RunResult::Error(explanation.into()))
-
    }
-

    /// Does the message indicate a result for the CI run?
    pub fn result(&self) -> Option<&RunResult> {
        if let Self::Finished { result } = self {