Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
feat! drop the RunResult::Error variant
Merged liw opened 2 years ago

It was never very clear how Failure and Error actually differ, and making the choice was thus unnecessarily difficult for an adapter implementation. Having just Failure is simpler.

We’ll re-introduce other variants if there are actual use cases and things aren’t vague.

Signed-off-by: Lars Wirzenius liw@liw.fi

3 files changed +0 -37 68fd1877 601abc94
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 {