mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 10:26:29 +02:00
32 lines
604 B
Go
32 lines
604 B
Go
package events
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
"github.com/stretchr/testify/assert"
|
|
"google.golang.org/protobuf/testing/protocmp"
|
|
)
|
|
|
|
func TestManager(t *testing.T) {
|
|
mgr := New()
|
|
|
|
received := make(chan Event, 1)
|
|
handle := mgr.Register(func(evt Event) {
|
|
received <- evt
|
|
})
|
|
assert.NotEmpty(t, handle)
|
|
|
|
expect := &IDPErrorEvent{Message: "TEST"}
|
|
mgr.Dispatch(expect)
|
|
|
|
assert.Eventually(t, func() bool {
|
|
select {
|
|
case evt := <-received:
|
|
return cmp.Equal(evt, expect, protocmp.Transform())
|
|
default:
|
|
return false
|
|
}
|
|
}, time.Second, time.Millisecond*20)
|
|
}
|