mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-18 16:17:03 +00:00
Fix flaky tests
This commit is contained in:
@ -24,6 +24,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -102,10 +103,13 @@ func TestEventLoopUpdateMessageFromLoop(t *testing.T) {
|
|||||||
// Event loop runs in goroutine and will be stopped by deferred mock clearing.
|
// Event loop runs in goroutine and will be stopped by deferred mock clearing.
|
||||||
go m.store.eventLoop.start()
|
go m.store.eventLoop.start()
|
||||||
|
|
||||||
require.Eventually(t, func() bool {
|
var err error
|
||||||
msg, err := m.store.getMessageFromDB("msg1")
|
assert.Eventually(t, func() bool {
|
||||||
|
var msg *pmapi.Message
|
||||||
|
msg, err = m.store.getMessageFromDB("msg1")
|
||||||
return err == nil && msg.Subject == newSubject
|
return err == nil && msg.Subject == newSubject
|
||||||
}, time.Second, 10*time.Millisecond)
|
}, time.Second, 10*time.Millisecond)
|
||||||
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEventLoopUpdateMessage(t *testing.T) {
|
func TestEventLoopUpdateMessage(t *testing.T) {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ var (
|
|||||||
testInput = []interface{}{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
testInput = []interface{}{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
||||||
wantOutput = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
wantOutput = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
||||||
testProcessSleep = 100 // ms
|
testProcessSleep = 100 // ms
|
||||||
runParallelTimeOverhead = 100 // ms
|
runParallelTimeOverhead = 150 // ms
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParallel(t *testing.T) {
|
func TestParallel(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user