From fbd9cc96d612c84675aaf3fc77510c7c85be115f Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 5 Jan 2024 16:05:10 +0200 Subject: [PATCH] test case: no RADICLE_NATIVE_CI set in environment Signed-off-by: Lars Wirzenius --- test-suite | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/test-suite b/test-suite index cea41f0..0de91fa 100755 --- a/test-suite +++ b/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, [