Publish curated ITWorx_MCP_Hub source from 8823cc4d95756a93815c82b8ab62215be3d63862
This commit is contained in:
1 parent
99caf1f968
commit
4766811350
3 files changed
+68
-4
No files matched your search
@@ -18,6 +18,70 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
SCRIPT = ROOT / "scripts" / "build_mcp_hub_release_images.py"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"failure,category,code",
|
||||
[("exit", "nonzero_exit", 7), ("timeout", "timeout", None), ("os", "exec_error", None)],
|
||||
)
|
||||
def test_fixed_stage_failure_reports_only_closed_phase_and_category(
|
||||
tmp_path, capsys, failure, category, code
|
||||
):
|
||||
marker = "fixture-sensitive-output-must-not-escape"
|
||||
|
||||
def runner(command, **kwargs):
|
||||
assert kwargs["stdout"] == subprocess.DEVNULL
|
||||
assert kwargs["stderr"] == subprocess.DEVNULL
|
||||
if failure == "timeout":
|
||||
raise subprocess.TimeoutExpired([marker], 1, output=marker, stderr=marker)
|
||||
if failure == "os":
|
||||
raise OSError(marker)
|
||||
return subprocess.CompletedProcess(command, code, stdout=marker, stderr=marker)
|
||||
|
||||
env = {
|
||||
name: "fixture"
|
||||
for name in (
|
||||
"GITEA_COMMIT_SHA",
|
||||
"APPOPS_SOURCE_TREE",
|
||||
"APPOPS_BUILD_ID",
|
||||
"APPOPS_BUILD_DATE",
|
||||
"SOURCE_DATE_EPOCH",
|
||||
)
|
||||
}
|
||||
with pytest.raises(producer.BuildRejected) as error:
|
||||
producer._build_contextforge(tmp_path, env, runner=runner)
|
||||
message = str(error.value)
|
||||
assert "stage=contextforge_build" in message
|
||||
assert f"category={category}" in message
|
||||
assert (f"exitCode={code}" in message) if code is not None else "exitCode=" not in message
|
||||
assert marker not in message
|
||||
assert marker not in "".join(capsys.readouterr())
|
||||
|
||||
|
||||
def test_unknown_stage_is_rejected_without_running_or_echoing_it(tmp_path):
|
||||
def runner(*args, **kwargs):
|
||||
pytest.fail("unknown stage must not execute")
|
||||
|
||||
with pytest.raises(producer.BuildRejected, match="^fixed release stage identifier is invalid$"):
|
||||
producer._execute(
|
||||
["fixture"],
|
||||
env={},
|
||||
cwd=tmp_path,
|
||||
timeout=1,
|
||||
stage="fixture-sensitive-stage",
|
||||
runner=runner,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("code", [True, "fixture-sensitive-exit", 2**40])
|
||||
def test_invalid_exit_code_is_not_echoed(tmp_path, code):
|
||||
def runner(command, **kwargs):
|
||||
return subprocess.CompletedProcess(command, code)
|
||||
|
||||
with pytest.raises(producer.BuildRejected, match="category=invalid_exit_code$"):
|
||||
producer._execute(
|
||||
["fixture"], env={}, cwd=tmp_path, timeout=1, stage="compose_local_build", runner=runner
|
||||
)
|
||||
|
||||
|
||||
def test_protected_metadata_uses_fixed_https_without_redirecting_credentials(monkeypatch):
|
||||
class Opener:
|
||||
def open(self, request, timeout):
|
||||
|
||||
Reference in new issue
Block a user