mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-23 10:26:44 +00:00
GODT-1474: Optimising live integration tests
- pkg/pmapi: Reduce max number of retries - test/features: tweak create mailbox scenarios. - test/context: change order of clean up steps - test/context: logger field - test/context: message preparation per username - test/context: check that eventID has changed after adding messages - test/features: make sure we wait 15sec before detecting import duplicates
This commit is contained in:
@ -62,7 +62,7 @@ func (ctx *TestContext) addCleanup(c func(), label string) {
|
||||
cleaner.file, cleaner.lineNumber = filepath.Base(file), line
|
||||
}
|
||||
|
||||
ctx.cleanupSteps = append(ctx.cleanupSteps, cleaner)
|
||||
ctx.cleanupSteps = append([]*Cleaner{cleaner}, ctx.cleanupSteps...)
|
||||
}
|
||||
|
||||
// addCleanupChecked adds an operation that may return an error to be performed at the end of the test.
|
||||
@ -83,5 +83,5 @@ func (ctx *TestContext) addCleanupChecked(f func() error, label string) {
|
||||
cleaner.file, cleaner.lineNumber = filepath.Base(file), line
|
||||
}
|
||||
|
||||
ctx.cleanupSteps = append(ctx.cleanupSteps, cleaner)
|
||||
ctx.cleanupSteps = append([]*Cleaner{cleaner}, ctx.cleanupSteps...)
|
||||
}
|
||||
|
||||
@ -107,9 +107,12 @@ func New() *TestContext {
|
||||
smtpLastResponses: make(map[string]*mocks.SMTPResponse),
|
||||
smtpResponseLocker: &sync.Mutex{},
|
||||
bddMessageIDsToAPIIDs: make(map[string]string),
|
||||
logger: logrus.StandardLogger(),
|
||||
logger: logrus.StandardLogger().WithField("ctx", "scenario"),
|
||||
}
|
||||
|
||||
ctx.logger.Info("New context")
|
||||
ctx.addCleanup(func() { ctx.logger.Info("Context end") }, "End of context")
|
||||
|
||||
// Ensure that the config is cleaned up after the test is over.
|
||||
ctx.addCleanupChecked(ctx.locations.Clear, "Cleaning bridge config data")
|
||||
|
||||
@ -163,5 +166,9 @@ func (ctx *TestContext) GetLastError() error {
|
||||
return ctx.lastError
|
||||
}
|
||||
|
||||
func (ctx *TestContext) MessagePreparationStarted() { ctx.pmapiController.LockEvents() }
|
||||
func (ctx *TestContext) MessagePreparationFinished() { ctx.pmapiController.UnlockEvents() }
|
||||
func (ctx *TestContext) MessagePreparationStarted(username string) {
|
||||
ctx.pmapiController.LockEvents(username)
|
||||
}
|
||||
func (ctx *TestContext) MessagePreparationFinished(username string) {
|
||||
ctx.pmapiController.UnlockEvents(username)
|
||||
}
|
||||
|
||||
@ -43,8 +43,8 @@ type PMAPIController interface {
|
||||
WasCalled(method, path string, expectedRequest []byte) bool
|
||||
WasCalledRegex(methodRegex, pathRegex string, expectedRequest []byte) (bool, error)
|
||||
GetCalls(method, path string) [][]byte
|
||||
LockEvents()
|
||||
UnlockEvents()
|
||||
LockEvents(username string)
|
||||
UnlockEvents(username string)
|
||||
}
|
||||
|
||||
func newPMAPIController(listener listener.Listener) (PMAPIController, pmapi.Manager) {
|
||||
|
||||
Reference in New Issue
Block a user