Skip to content

test: add comprehensive Realtime test coverage #755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 29, 2025
Merged

Conversation

grdsdev
Copy link
Collaborator

@grdsdev grdsdev commented Jul 29, 2025

Summary

  • Add 84 comprehensive tests across 8 new test files for Realtime module
  • Covers all non-deprecated files in Sources/Realtime/ directory
  • Provides complete test coverage for core functionality including PostgreSQL actions, WebSocket handling, error management, and configuration

Test Coverage Added

  • PostgresActionTests.swift: 15 tests for PostgreSQL change events and data structures
  • RealtimeErrorTests.swift: 5 tests for error handling and descriptions
  • RealtimeJoinConfigTests.swift: 22 tests for channel join configurations
  • PushV2Tests.swift: 4 tests for message pushing functionality
  • WebSocketTests.swift: 8 tests for WebSocket protocol abstraction
  • ExportsTests.swift: 1 test validating @_exported imports

Test Quality Features

✅ Comprehensive API coverage for all public interfaces
✅ Error handling and edge case validation
✅ Protocol conformance testing (Codable, Equatable, Hashable)
✅ JSON encoding/decoding with various data types
✅ Mock objects for WebSocket testing without external dependencies
✅ Async/await support where applicable
✅ Boundary condition testing with nil values and empty data

Test plan

  • All 84 new tests pass successfully
  • No existing tests broken by changes
  • Tests follow existing project conventions (XCTest, @testable import, naming patterns)
  • Comprehensive coverage of non-deprecated Realtime functionality
  • Tests validate error conditions and edge cases appropriately

🤖 Generated with Claude Code

grdsdev and others added 3 commits July 29, 2025 05:42
Add 84 new tests across 8 test files covering core Realtime functionality:
- PostgresAction: 15 tests for PostgreSQL change events and data structures
- RealtimeError: 5 tests for error handling and descriptions
- Types: 14 tests for client options and configuration
- RealtimeJoinConfig: 22 tests for channel join configurations
- PushV2: 4 tests for message pushing functionality
- WebSocket: 8 tests for WebSocket protocol abstraction
- URLSessionWebSocket: 15 tests for URLSession WebSocket implementation
- Exports: 1 test validating @_exported imports

All tests follow existing project conventions and provide comprehensive coverage
for public APIs, error handling, edge cases, and protocol conformances.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fix all concurrency safety errors that were causing build failures in Xcode 15.4:

- URLSessionWebSocketTests.swift: Fixed mutations of captured variables in @sendable closures
- WebSocketTests.swift: Fixed mutation of receivedEvent variable in @sendable closure

Used thread-safe wrapper classes with NSLock to ensure proper synchronization while
maintaining the same test functionality and coverage.

All 84 tests now pass successfully with strict concurrency checking enabled.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coveralls
Copy link

coveralls commented Jul 29, 2025

Pull Request Test Coverage Report for Build 16592753250

Details

  • 1 of 2 (50.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.4%) to 77.977%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Sources/Realtime/RealtimeClientV2.swift 0 1 0.0%
Totals Coverage Status
Change from base Build 16569112450: 1.4%
Covered Lines: 5403
Relevant Lines: 6929

💛 - Coveralls

grdsdev and others added 4 commits July 29, 2025 06:20
Replace custom thread-safe wrapper classes with the existing LockIsolated type
that's already used throughout the codebase for synchronized critical state.

This provides better consistency with the project's existing patterns and
reduces code duplication. Added ConcurrencyExtras import to access LockIsolated.

All 84 tests continue to pass with this cleaner implementation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Applied swift-format to all modified test files to ensure consistent
code style throughout the project:

- URLSessionWebSocketTests.swift
- WebSocketTests.swift
- ExportsTests.swift
- PostgresActionTests.swift
- PushV2Tests.swift
- RealtimeErrorTests.swift
- RealtimeJoinConfigTests.swift
- TypesTests.swift

All 84 tests continue to pass after formatting.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@grdsdev grdsdev requested a review from o-santi July 29, 2025 10:26
@grdsdev grdsdev assigned mandarini and unassigned mandarini Jul 29, 2025
@grdsdev grdsdev requested review from mandarini and dshukertjr July 29, 2025 10:26
@grdsdev grdsdev merged commit 771ee18 into main Jul 29, 2025
18 checks passed
@grdsdev grdsdev deleted the tests/realtime branch July 29, 2025 12:01
@supabase-releaser
Copy link

🎉 This PR is included in version 2.31.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants