Fixed test coverage gap where tests were only parsing JSON manually
without actually invoking the parseAndSetStructuredOutputs function.
Changes:
- Export parseAndSetStructuredOutputs for testing
- Rewrite tests to use spyOn() to mock @actions/core functions
- Add tests that actually call the function and verify:
- core.setOutput() called with correct JSON string
- core.info() called with correct field count
- Error thrown when result exists but structured_output undefined
- Error thrown when no result message exists
- Handles special characters in field names (hyphens, dots, @ symbols)
- Handles arrays and nested objects correctly
- File errors propagate correctly
All 8 tests now properly test the actual implementation with full
coverage of success and error paths.
Addresses review comment: https://github.com/anthropics/claude-code-action/pull/683#discussion_r2539770213🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Since GitHub Actions composite actions cannot expose dynamic outputs,
individual field outputs were not accessible anyway and only added
complexity and collision risk.
Simplified by:
- Removing individual core.setOutput() calls for each field
- Removing RESERVED_OUTPUTS check (no longer needed)
- Removing sanitizeOutputName, convertToString, MAX_OUTPUT_SIZE helpers
- Removing related unit tests for removed functionality
Users access all fields via single structured_output JSON string:
fromJSON(steps.<id>.outputs.structured_output).field_name
Or with jq:
echo '${{ steps.<id>.outputs.structured_output }}' | jq '.field_name'
All tests pass (462 tests).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>