From 5d246d449c3c12c79d9086571424f57818782141 Mon Sep 17 00:00:00 2001 From: Michal Horejsek Date: Thu, 14 Jan 2021 09:31:36 +0100 Subject: [PATCH] Fix flaky tests about notifying changes --- internal/store/store_test.go | 18 +++++++++++++++--- unreleased.md | 8 ++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/internal/store/store_test.go b/internal/store/store_test.go index f851ff0d..603cc81b 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -107,12 +107,16 @@ func (mocks *mocksForStore) newStoreNoEvents(combinedMode bool, msgs ...*pmapi.M mocks.client.EXPECT().CountMessages("") // Call to get latest event ID and then to process first event. + eventAfterSyncRequested := make(chan struct{}) mocks.client.EXPECT().GetEvent("").Return(&pmapi.Event{ EventID: "firstEventID", }, nil) - mocks.client.EXPECT().GetEvent("firstEventID").Return(&pmapi.Event{ - EventID: "latestEventID", - }, nil) + mocks.client.EXPECT().GetEvent("firstEventID").DoAndReturn(func(_ string) (*pmapi.Event, error) { + close(eventAfterSyncRequested) + return &pmapi.Event{ + EventID: "latestEventID", + }, nil + }) mocks.client.EXPECT().ListMessages(gomock.Any()).Return(msgs, len(msgs), nil).AnyTimes() for _, msg := range msgs { @@ -131,6 +135,14 @@ func (mocks *mocksForStore) newStoreNoEvents(combinedMode bool, msgs ...*pmapi.M require.NoError(mocks.tb, err) // We want to wait until first sync has finished. + // Checking that event after sync was reuested is not the best way to + // do the check, because sync could take more time, but sync is going + // in background and if there is no message to wait for, we don't have + // anything better. + select { + case <-eventAfterSyncRequested: + case <-time.After(5 * time.Second): + } require.Eventually(mocks.tb, func() bool { for _, msg := range msgs { _, err := mocks.store.getMessageFromDB(msg.ID) diff --git a/unreleased.md b/unreleased.md index 4555600a..4799c8b2 100644 --- a/unreleased.md +++ b/unreleased.md @@ -31,6 +31,14 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/) ### Removed * GODT-208 Remove deprecated use of BuildNameToCertificate. +### Fixed +* GODT-922 Fix panic during restarting the bridge. +* GODT-945 Fix panic in integration tests caused by concurrent map writes. +* GODT-732 Fix usage of fontawesome. +* GODT-951 Properly parse message with long lines in header and long header split to multiple lines (upgrading to latest go-message). +* GODT-894 Fix panic when sending while account is logging in. +* GODT-946 Fix flaky tests notifying changes. + ### Changed * GODT-97 Don't log errors caused by SELECT "".