octoplex/internal/event/bus_test.go
Rob Watson 1f4a931903
Some checks are pending
ci-build / lint (push) Waiting to run
ci-build / build (push) Blocked by required conditions
ci-build / release (push) Blocked by required conditions
ci-scan / Analyze (go) (push) Waiting to run
ci-scan / Analyze (actions) (push) Waiting to run
fix(app): event ordering
Use a single channel per consumer, instead of one channel per
consumer/event tuple. This ensures that overall ordering of events
remains consistent, and avoids introducing subtle race conditions.
2025-04-25 17:42:49 +02:00

30 lines
619 B
Go

package event_test
import (
"testing"
"git.netflux.io/rob/octoplex/internal/event"
"git.netflux.io/rob/octoplex/internal/testhelpers"
"github.com/stretchr/testify/assert"
)
func TestBus(t *testing.T) {
bus := event.NewBus(testhelpers.NewTestLogger(t))
ch1 := bus.Register()
ch2 := bus.Register()
evt := event.MediaServerStartedEvent{
RTMPURL: "rtmp://rtmp.example.com/live",
RTMPSURL: "rtmps://rtmp.example.com/live",
}
go func() {
bus.Send(evt)
bus.Send(evt)
}()
assert.Equal(t, evt, (<-ch1).(event.MediaServerStartedEvent))
assert.Equal(t, evt, (<-ch2).(event.MediaServerStartedEvent))
}