Skip to content

test: add comprehensive test suite for dream-doctor.sh#373

Open
bugman-007 wants to merge 2 commits intoLight-Heart-Labs:mainfrom
bugman-007:test/dream-doctor-suite
Open

test: add comprehensive test suite for dream-doctor.sh#373
bugman-007 wants to merge 2 commits intoLight-Heart-Labs:mainfrom
bugman-007:test/dream-doctor-suite

Conversation

@bugman-007
Copy link
Contributor

Summary

  • Add comprehensive test coverage for dream-doctor.sh diagnostic tool
  • Create tests/test-dream-doctor.sh with 11 test cases covering all critical functionality
  • Integrate test into CI pipeline via .github/workflows/test-linux.yml

Motivation

dream-doctor.sh is a critical diagnostic tool (207 lines) that:

  • Generates machine-readable diagnostics reports for installer readiness
  • Produces CI artifacts (doctor.json, macos-doctor.json)
  • Used in installer simulation harness
  • Had zero test coverage despite its importance

This PR closes the testing gap by following the same pattern as test-health-check.sh.

Test Coverage

The new test suite validates:

  1. Script exists and is runnable
  2. --help flag displays usage information
  3. Runs without shell errors (no unbound variables, syntax errors)
  4. Exit codes are valid (0=success, 1=error)
  5. Creates JSON output file at specified path
  6. Output is valid JSON (via jq)
  7. All required top-level fields present (version, generated_at, autofix_hints, capability_profile, preflight, runtime, summary)
  8. autofix_hints is an array
  9. runtime section has correct boolean fields (docker_cli, docker_daemon, compose_cli, dashboard_http, webui_http)
  10. summary section has correct numeric fields (preflight_blockers, preflight_warnings)
  11. Script is executable or runnable via bash

Test Results

$ bash tests/test-dream-doctor.sh
╔═══════════════════════════════════════════════╗
║   dream-doctor.sh Test Suite                  ║
╚═══════════════════════════════════════════════╝

  ✓ PASS dream-doctor.sh exists
  ✓ PASS dream-doctor.sh --help displays usage
  ✓ PASS dream-doctor.sh runs without shell errors
  ✓ PASS dream-doctor.sh exit code is valid (0|1): 0
  ✓ PASS dream-doctor.sh creates output file
  ✓ PASS dream-doctor.sh output is valid JSON
  ✓ PASS dream-doctor.sh output contains all required fields
  ✓ PASS dream-doctor.sh autofix_hints is an array
  ✓ PASS dream-doctor.sh runtime section has correct boolean fields
  ✓ PASS dream-doctor.sh summary section has correct numeric fields
  ✓ PASS dream-doctor.sh is runnable (bash or executable)

Result: 11 passed, 0 failed

CI Integration

Added test step to .github/workflows/test-linux.yml between "Health Check Tests" and "Validate Env Tests" to ensure dream-doctor is validated on every PR and push to main.

Impact

  • Ensures diagnostic tool reliability for users troubleshooting installation issues
  • Validates JSON structure used by installer simulation and CI artifacts
  • Prevents regressions in critical diagnostic functionality
  • Aligns with project's testing standards

Copy link
Collaborator

@Lightheartdevs Lightheartdevs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: test suite for dream-doctor.sh

Bug: Test 10 always passes

if [[ -x "$ROOT_DIR/scripts/dream-doctor.sh" ]] || true; then

The || true makes this unconditionally pass — dead test. Direct CLAUDE.md violation (rule 4: never || true). Remove it or drop the test (tests 1 and 3 already prove runnability).

CLAUDE.md violation: 2>/dev/null

Lines 96, 103, 117, 127, 138, 149 — multiple jq calls suppress stderr. CLAUDE.md rule 4 prohibits this. The set +e / conditional pattern already handles non-zero exits. Let jq errors surface.

Tests are structural, not behavioral

All 11 tests are JSON schema checks (field exists, field is boolean, valid JSON). None test actual doctor behavior — does it detect missing Docker? Does autofix_hints populate? The suite would pass if doctor logic were completely wrong as long as JSON shape is correct. Add 2-3 behavioral tests with environment mocking.

CI conflict with PR #376

Both PRs add a step to .github/workflows/test-linux.yml at the same insertion point. Whichever merges second hits a merge conflict.

@Lightheartdevs
Copy link
Collaborator

What's needed to get this merged:

  1. Remove || true on test Add PHILOSOPHY.md and reframe README as methodology #10 line 155 — makes it always pass, dead test
  2. Remove all 2>/dev/null on jq calls (lines 96, 103, 117, 127, 138, 149) — let errors surface
  3. Add 2-3 behavioral tests — e.g., mock a missing Docker binary and verify the doctor detects it, or check that autofix_hints populates correctly. Current tests only verify JSON shape, not doctor logic.

@bugman-007
Copy link
Contributor Author

I addressed review feedback for dream-doctor test suite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants