Skip to content

fix(test): guard prerequisites test for missing yq dependency #47

Description

@fullsend-ai-retro

What happened

In PR #40, the triage pipeline was updated to support the question action and label-category consistency guards. The post-triage-test.sh test suite includes a test case prerequisites-creates-allowed-issue that sets up a config.yaml with an allowlist and expects the post-script to read it and create an issue in the allowed repo. However, the post-script reads config.yaml using yq, and when yq is not installed, it emits a warning and disables cross-repo issue creation entirely. The test does not account for this — it expects issue creation to succeed regardless of yq availability. Running bash scripts/post-triage-test.sh today produces:

FAIL: prerequisites-creates-allowed-issue — expected gh call pattern not found

All other tests pass (47/48).

What could go better

The test should either skip when yq is unavailable or provide a mock yq binary alongside the mock gh. The production code handles missing yq gracefully (line 141-142 of post-triage.sh emits a ::warning:: and falls through), but the test assumes yq is always present. This is likely an oversight rather than a design choice — the test fixture creates a config.yaml with allowlist entries specifically to exercise the allowed-target path, which requires yq to parse.

Confidence: High. The failure is reproducible and the root cause is clear.

Proposed change

In scripts/post-triage-test.sh, add a mock yq binary to ${MOCK_BIN} that reads the config.yaml and returns the allowlist values, similar to how the mock gh and fullsend binaries work. Alternatively, add a guard that skips the prerequisites-creates-allowed-issue and prerequisites-skips-disallowed-target tests when yq is not available, with a clear skip message:

if ! command -v yq &>/dev/null && [[ ! -x "${MOCK_BIN}/yq" ]]; then
  echo "SKIP: ${test_name} — yq not available"
  return
fi

The mock approach is preferred because it makes the test hermetic — it will pass regardless of the host environment.

Validation criteria

Running bash scripts/post-triage-test.sh in an environment without yq installed should produce 0 test failures. All 48 test cases should either PASS or show an explicit SKIP message.


Generated by retro agent from #40

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions