mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-23 10:26:44 +00:00
test: add test with changing address order
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
// Code generated by ./credits.sh at Fri Apr 24 08:21:38 CEST 2020. DO NOT EDIT.
|
||||
// Code generated by ./credits.sh at Wed May 6 07:17:01 CEST 2020. DO NOT EDIT.
|
||||
|
||||
package bridge
|
||||
|
||||
|
||||
@ -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")
|
||||
}
|
||||
|
||||
@ -46,6 +46,11 @@ func (store *Store) TestGetEventLoop() *eventLoop { //nolint[golint]
|
||||
return store.eventLoop
|
||||
}
|
||||
|
||||
// TestGetLastEvent returns last event processed by the store's event loop.
|
||||
func (store *Store) TestGetLastEvent() *pmapi.Event { //nolint[golint]
|
||||
return store.eventLoop.currentEvent
|
||||
}
|
||||
|
||||
// TestGetStoreFilePath returns the filepath of the store's database file.
|
||||
func (store *Store) TestGetStoreFilePath() string {
|
||||
return store.filePath
|
||||
|
||||
Reference in New Issue
Block a user