Other: Get test events before starting bridge to ensure all are captured

This commit is contained in:
James Houlahan
2022-10-13 02:33:20 +02:00
parent ef2dea89b4
commit a4852c1b36
3 changed files with 76 additions and 39 deletions

View File

@ -8,6 +8,7 @@ import (
"time"
"github.com/Masterminds/semver/v3"
"github.com/ProtonMail/gluon/queue"
"github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/v2/internal/vault"
)
@ -249,9 +250,9 @@ func (s *scenario) bridgeSendsAForcedUpdateEvent() error {
})
}
func try[T any](inCh <-chan T, wait time.Duration, fn func(T) error) error {
func try[T any](inCh *queue.QueuedChannel[T], wait time.Duration, fn func(T) error) error {
select {
case event := <-inCh:
case event := <-inCh.GetChannel():
return fn(event)
case <-time.After(wait):
@ -259,6 +260,6 @@ func try[T any](inCh <-chan T, wait time.Duration, fn func(T) error) error {
}
}
func get[T any](inCh <-chan T, fn func(T) error) error {
return fn(<-inCh)
func get[T any](inCh *queue.QueuedChannel[T], fn func(T) error) error {
return fn(<-inCh.GetChannel())
}