Skip to content

test(ralph-loop): add comprehensive unit tests for state library - #207

Merged
baleen37 merged 1 commit into
mainfrom
chore/remove-loop
Jan 29, 2026
Merged

test(ralph-loop): add comprehensive unit tests for state library#207
baleen37 merged 1 commit into
mainfrom
chore/remove-loop

Conversation

@baleen37

@baleen37 baleen37 commented Jan 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add 17 new unit tests for state.sh library functions
  • Add tests for completion promise tag extraction
  • Add tests for multibyte character handling (UTF-8, emoji)
  • Add edge case tests
  • Fix existing session_id sanitization tests

Test plan

  • All 41 BATS tests pass
  • Full test suite passes (132 tests)

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Tests
    • Significantly expanded test suite with comprehensive unit tests covering session validation, YAML parsing, iteration parameter extraction, and special character handling including UTF-8 and emojis.
    • Added integration tests for setup and hook scripts to validate configuration parameters, file handling, and promise extraction logic with proper regex handling and whitespace normalization.

✏️ Tip: You can customize this high-level summary in your review settings.

Add unit tests for:
- state.sh library functions (validate_session_id, parse_frontmatter,
  get_iteration, get_max_iterations, get_completion_promise)
- Completion promise tag extraction verification
- Multibyte character handling (UTF-8, emoji)
- Edge cases (empty values, special chars, dashes in prompt)

Also fix existing session_id sanitization tests to check for
validate_session_id function calls instead of direct regex patterns.

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jan 29, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR adds comprehensive unit tests for the ralph-loop plugin, verifying session validation, YAML parsing, iteration tracking, promise extraction, and edge cases including UTF-8/emoji handling and special characters across multiple shell scripts.

Changes

Cohort / File(s) Summary
Unit Tests for ralph-loop Plugin
plugins/ralph-loop/tests/ralph-loop-specific.bats
Expanded test suite with 339 lines of new BATS tests covering: session-start-hook.sh, stop-hook.sh, cancel-ralph.sh validation; state.sh library functions (validate_session_id, parse_frontmatter, get_iteration, get_max_iterations, get_completion_promise); setup-ralph-loop.sh validation (numeric constraints, prompt presence, RALPH_SESSION_ID, state file duplication); promise extraction with regex patterns and multiline handling; UTF-8 and emoji support. Note: duplicate test blocks detected in diff.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A tester's delight, so thorough and bright,
Functions now validated, from left to the right!
Edge cases handled, UTF-8 in place,
These tests will keep bugs from the codebase's face! 🎉

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant