package main import ( "testing" "github.com/stretchr/testify/assert" ) func TestSendingNotifications(t *testing.T) { assert := assert.New(t) notifier := NewNotifier[string](3) notifier.SendAndCreate("1", "a") notifier.SendAndCreate("1", "b") notifier.SendAndCreate("1", "c") ch := notifier.Listeners["1"] a := <-ch b := <-ch c := <-ch assert.Equal(a, "a") assert.Equal(b, "b") assert.Equal(c, "c") } func TestFullBuffer(t *testing.T) { assert := assert.New(t) notifier := NewNotifier[string](1) notifier.SendAndCreate("1", "a") err := notifier.SendAndCreate("1", "b") assert.Error(err) }