test: add test with changing address order

This commit is contained in:
James Houlahan
2020-05-06 09:57:34 +02:00
parent c61e8bdc71
commit 2d200f6f8c
19 changed files with 202 additions and 23 deletions

View File

@ -34,6 +34,7 @@ const pollIntervalSpread = 5 * time.Second
type eventLoop struct {
cache *Cache
currentEventID string
currentEvent *pmapi.Event
pollCh chan chan struct{}
stopCh chan struct{}
notifyStopCh chan struct{}
@ -136,13 +137,18 @@ func (loop *eventLoop) start() { // nolint[funlen]
loop.log.WithField("lastEventID", loop.currentEventID).Warn("Subscription stopped")
}()
t := time.NewTicker(pollInterval - pollIntervalSpread)
defer t.Stop()
loop.hasInternet = true
go loop.pollNow()
loop.loop()
}
// loop is the main body of the event loop.
func (loop *eventLoop) loop() {
t := time.NewTicker(pollInterval - pollIntervalSpread)
defer t.Stop()
for {
var eventProcessedCh chan struct{}
select {
@ -251,6 +257,8 @@ func (loop *eventLoop) processNextEvent() (more bool, err error) { // nolint[fun
return false, errors.Wrap(err, "failed to get event")
}
loop.currentEvent = event
if event == nil {
return false, errors.New("received empty event")
}