Files
datastore/ci/tests/test_workflow_input_parsing.py
Alexei Fedotov 3d9e8fa701 Reject empty input names in --workflow-input parser
Previously `--workflow-input "=25.4,type=patch"` silently produced
`{"": "25.4"}`, hiding typos in required input names and making
downstream `Info.get_workflow_input_value` lookups fail unexpectedly.
Skip such entries with a warning so malformed inputs are surfaced
immediately. Extend the parser test to cover the new case.
2026-05-11 12:34:35 +02:00

30 lines
871 B
Python

"""
Test for Runner._parse_workflow_inputs.
Covers the parser used by the `--workflow-input` CLI flag, which accepts
comma-separated `name=value` pairs and writes them to workflow_inputs.json
for jobs to read via `Info.get_workflow_input_value`.
"""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../.."))
from ci.praktika.runner import Runner
def test_parse_workflow_inputs():
# Exercises whitespace stripping, empty value, value containing `=`,
# skipping of malformed entries (no `=`), and rejection of entries
# with an empty name (e.g. `=25.4`) in a single call.
inputs = Runner._parse_workflow_inputs(
" ref = main , type=patch , dry-run= , expr=a=b=c , bogus , =25.4 "
)
assert inputs == {
"ref": "main",
"type": "patch",
"dry-run": "",
"expr": "a=b=c",
}