mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 00:40:25 +02:00
directory: save IDP errors to databroker, put event handling in dedicated package (#2957)
This commit is contained in:
parent
2f328e7de0
commit
64ee7eca5c
13 changed files with 451 additions and 83 deletions
32
internal/events/manager_test.go
Normal file
32
internal/events/manager_test.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue