Add unit tests for renderCatalogStatus.py reason_to_link function

Open Beginner friendly
#3,169 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
86/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
testing

Research direction

Start with scripts/renderCatalogStatus.py and the existing patterns in scripts/tests/, especially test_generatePluginBuildInfo.py, test_generateCatalogIndex.py, and test_plugin_utils.py. Add scripts/tests/test_renderCatalogStatus.py covering the five requested reason_to_link cases, then run pytest tests/ -v or validate-catalog-scripts.yaml. Done means the tests pass and protect the documented link-rendering paths.

Written by the indexing model from the issue text.

Description

enhancement feature non-workspace-changes stale triaged

What happened

PR #3168 modified the reason_to_link function in scripts/renderCatalogStatus.py, adding new string parsing logic that splits failure reasons into a prefix (linked to a troubleshooting anchor) and a remainder (linked to the OCI registry). The PR was self-merged in 90 seconds with zero code reviews — the review agent was triggered but could not complete before merge (run 31094385523). The function now has three code paths: prefix-only reasons, prefix-with-remainder reasons, and unrecognized reasons. None of these paths are tested.

What could go better

Eight other Python scripts in scripts/ have corresponding test files in scripts/tests/ (e.g., test_generatePluginBuildInfo.py, test_generateCatalogIndex.py, test_plugin_utils.py), but renderCatalogStatus.py has none. The CI workflow validate-catalog-scripts.yaml already runs pytest tests/ -v, so any new test file would be automatically included. The parsing logic in reason_to_link — splitting on prefix length, stripping colons, conditionally calling oci_ref_to_link — is the kind of string manipulation that benefits most from regression tests. Without tests, future changes (by humans or agents) could silently break status page link rendering on the GitHub Wiki. Confidence is high that this is a real gap: the code paths are non-trivial, the test infrastructure exists, and the script renders user-facing output.

Proposed change

Create scripts/tests/test_renderCatalogStatus.py with unit tests for reason_to_link. Cover at minimum: (1) reason with no matching prefix returns the raw string unchanged, (2) reason matching a prefix with no remainder returns a troubleshooting anchor link, (3) reason matching a prefix with a colon-separated OCI ref returns both a troubleshooting link and an OCI registry link, (4) the troubleshooting_content parameter controls whether the prefix becomes a link or stays plain text, (5) empty reason string is handled gracefully. The existing test pattern in scripts/tests/ (pytest with fixtures in scripts/tests/fixtures/) should be followed. Consider also testing render_tier integration with reason_to_link if feasible.

Validation criteria

A scripts/tests/test_renderCatalogStatus.py file exists with at least 5 test cases covering the documented code paths. The tests pass in the existing validate-catalog-scripts.yaml CI workflow without configuration changes. The next PR that modifies reason_to_link has regression protection.


Generated by retro agent from https://github.com/redhat-developer/rhdh-plugin-export-overlays/pull/3168

Dominant language
TypeScript
Stars
9
Forks
72
Avg merge
3d 9h
Merged PRs (30d)
133

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from redhat-developer/rhdh-plugin-export-overlays

All issues in redhat-developer/rhdh-plugin-export-overlays

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.