directory: save IDP errors to databroker, put event handling in dedicated package (#2957)

This commit is contained in:
Caleb Doxsey 2022-01-28 15:15:32 -07:00 committed by GitHub
parent 2f328e7de0
commit 64ee7eca5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 451 additions and 83 deletions

View 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)
}