Skip to content

feat: add Broadcasting module tests and scaffolding#137

Open
goravel-coder wants to merge 8 commits into
masterfrom
feat/broadcasting-tests
Open

feat: add Broadcasting module tests and scaffolding#137
goravel-coder wants to merge 8 commits into
masterfrom
feat/broadcasting-tests

Conversation

@goravel-coder

@goravel-coder goravel-coder commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add Broadcasting module integration tests covering dispatch and channel authorization
  • Add mock-based tests for facades.Broadcast().Channel() and facades.Broadcast().Dispatch()
  • Add RelayCloud Docker service to docker-compose.yml for automated end-to-end broadcast testing

Why

This PR adds full test coverage for the new Broadcasting module from goravel/framework#1525. The module enables real-time event delivery through Pusher, Log, and Null drivers. Events implement the ShouldBroadcast contract and are dispatched through the queue system for non-blocking delivery.

// routes/channels.go
facades.Broadcast().Channel("orders.{orderId}", func(user any, channelName string, params map[string]string) bool {
	userID := user.(map[string]any)["id"]
	return userID != nil && params["orderId"] != ""
})
// Dispatch from a controller
facades.Broadcast().Dispatch(&broadcasting.OrderShipped{
	OrderID:    1,
	OrderData:  map[string]any{"id": 1, "name": "Test Order"},
	ShouldFire: true,
})

A RelayCloud container (darknautica/relay:latest) runs as a docker-compose service alongside the existing test infrastructure, providing a Pusher-compatible WebSocket server for real broadcast verification.

- Add config/broadcasting.go with pusher, log, null drivers
- Add app/facades/broadcast.go facade wrapper
- Add routes/channels.go channel auth callbacks
- Add app/broadcasting/events.go implementing all ShouldBroadcast* contracts
- Add tests/feature/broadcast_test.go: 13 integration tests
- Add mock examples: BroadcastChannel, BroadcastDispatch
- Register broadcasting service provider
- Wire routes.Channels() in bootstrap
- Bump framework to 8b12654
@goravel-coder
goravel-coder requested a review from a team as a code owner July 24, 2026 08:40
opencode added 3 commits July 24, 2026 16:57
- Add relay service to docker-compose.yml using darknautica/relay:latest
- Add docker/relay/apps.json with test credentials
- Add SetupSuite/TearDownSuite to manage relay container lifecycle
- Relay tests now run automatically as part of the test suite
Comment thread tests/feature/broadcast_test.go Outdated
Comment on lines +37 to +44
config := facades.Config()
config.Add("broadcasting.connections.log", map[string]any{
"driver": "log",
})
config.Add("broadcasting.connections.null", map[string]any{
"driver": "null",
})
config.Add("broadcasting.default", "null")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do you add this? The configuration includes them. You should test different connections like https://github.com/goravel/example/blob/v1.18.x/tests/feature/redis_test.go

opencode added 4 commits July 24, 2026 17:12
Connections are already defined in config/broadcasting.go.
Only switch the default driver per test, matching the redis_test.go pattern.
Split dispatch tests into LogDriver, NullDriver, and PusherDriver.
Each test explicitly switches the default connection and verifies
driver-specific behavior rather than relying on a single default.
Interactive browser page that connects to RelayCloud via WebSocket
and subscribes to channels to verify real-time broadcasting.
Served at /broadcast.html.
RelayCloud uses Bearer token auth for REST API, not Pusher HMAC.
pusher-http-go and the Goravel pusher driver are incompatible.
Keep log and null driver tests which work correctly.
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