Skip to content

Commit

Permalink
test: fix tests for asserting wrong handler callbacks
Browse files Browse the repository at this point in the history
Signed-off-by: Bernd Warmuth <[email protected]>
  • Loading branch information
warber committed Nov 7, 2024
1 parent 2654d57 commit 714c7f8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions openfeature/event_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,10 +988,16 @@ func TestEventHandler_HandlersRunImmediately(t *testing.T) {
rsp <- e
}

//AddHandler(ProviderReady, &callback) // TODO: hard to test, because callback is executed on handler registration
AddHandler(ProviderReady, &callback)
<-rsp // ignore first READY event which gets emitted after registration
AddHandler(ProviderStale, &callback)
AddHandler(ProviderConfigChange, &callback)

// assert client transitioned to ERROR
eventually(t, func() bool {
return GetApiInstance().GetClient().State() == ErrorState
}, time.Second, time.Millisecond*100, "")

select {
case <-rsp:
t.Errorf("event must not emit for this handler")
Expand Down Expand Up @@ -1025,10 +1031,16 @@ func TestEventHandler_HandlersRunImmediately(t *testing.T) {
rsp <- e
}

//AddHandler(ProviderReady, &callback) // TODO: hard to test, because callback is executed on handler registration
AddHandler(ProviderReady, &callback)
<-rsp // ignore first READY event which gets emitted after registration
AddHandler(ProviderError, &callback)
AddHandler(ProviderConfigChange, &callback)

// assert client transitioned to STALE
eventually(t, func() bool {
return GetApiInstance().GetClient().State() == StaleState
}, time.Second, time.Millisecond*100, "")

select {
case <-rsp:
t.Errorf("event must not emit for this handler")
Expand Down

0 comments on commit 714c7f8

Please sign in to comment.