Radish alpha
r
rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE
Radicle CI adapter for native CI
Radicle
Git
test case: no RADICLE_NATIVE_CI set in environment
Lars Wirzenius committed 2 years ago
commit fbd9cc96d612c84675aaf3fc77510c7c85be115f
parent ba301ea
1 file changed +26 -4
modified test-suite
@@ -84,6 +84,27 @@ class Suite:
        self.assert_triggered(resps[0])
        self.assert_success(resps[1])

+
    def test_without_config_env_var(self):
+
        git = Git(os.path.join(self.tmp, "no-config"))
+
        git.init()
+
        git.write("README.md", "README")
+
        native = NativeYaml("echo hello world")
+
        debug(f"native.yaml: {native.yaml()}")
+
        git.write(".radicle/native.yaml", native.yaml())
+
        git.commit("first commit")
+
        commit = git.head()
+
        self.rad.init(git)
+
        rid = self.rad.rid(git)
+
        trigger = Trigger(rid, commit)
+
        ci = NativeCI(self.rad, self.config)
+
        ci.without_config()
+
        exit, resps = ci.run(trigger)
+
        debug(f"exit: {exit}")
+
        debug(f"responses: {resps}")
+
        assert exit != 0
+
        assert len(resps) == 0
+
        # FIXME: check stderr that env var RADICLE_NATIVE_CI is mentioned
+

    def test_command_fails(self):
        exit, resps = self._test_case("cmd-fails", "false")
        assert exit != 0
@@ -230,14 +251,15 @@ class NativeCI:
    def __init__(self, rad, config):
        self.rad_home = rad.rad_home
        self.config = config.path
-

-
    def env(self):
-
        return {
+
        self.env = {
            "RAD_HOME": self.rad_home,
            "RADICLE_NATIVE_CI": self.config,
            "RADICLE_NATIVE_CI_LOG": "debug",
        }

+
    def without_config(self):
+
        del self.env["RADICLE_NATIVE_CI"]
+

    def run(self, request):
        p = run(
            [
@@ -246,7 +268,7 @@ class NativeCI:
                "-q",
            ],
            input=request.json(),
-
            env=self.env(),
+
            env=dict(self.env),
            may_fail=True,
        )
        return p.returncode, [