mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 15:46: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:
@ -37,6 +37,7 @@ func StoreSetupFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^there are (\d+) messages in mailbox(?:es)? "([^"]*)" for "([^"]*)"$`, thereAreSomeMessagesInMailboxesForUser)
|
||||
s.Step(`^there are messages for "([^"]*)" as follows$`, thereAreSomeMessagesForUserAsFollows)
|
||||
s.Step(`^there are (\d+) messages in mailbox(?:es)? "([^"]*)" for address "([^"]*)" of "([^"]*)"$`, thereAreSomeMessagesInMailboxesForAddressOfUser)
|
||||
s.Step(`^wait for Sphinx to create duplication indices$`, waitForSphinx)
|
||||
}
|
||||
|
||||
func thereIsUserWithMailboxes(bddUserID string, mailboxes *godog.Table) error {
|
||||
@ -75,18 +76,18 @@ func thereAreMessagesInMailboxesForUser(mailboxNames, bddUserID string, messages
|
||||
}
|
||||
|
||||
func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bddUserID string, messages *godog.Table) error {
|
||||
// It is needed to prevent event processing before syncing these message
|
||||
// otherwise the seqID and UID will be in reverse order. The
|
||||
// synchronization add newest message first, the eventloop adds the oldest
|
||||
// message first.
|
||||
ctx.MessagePreparationStarted()
|
||||
defer ctx.MessagePreparationFinished()
|
||||
|
||||
account := ctx.GetTestAccountWithAddress(bddUserID, bddAddressID)
|
||||
if account == nil {
|
||||
return godog.ErrPending
|
||||
}
|
||||
|
||||
// It is needed to prevent event processing before syncing these message
|
||||
// otherwise the seqID and UID will be in reverse order. The
|
||||
// synchronization add newest message first, the eventloop adds the oldest
|
||||
// message first.
|
||||
ctx.MessagePreparationStarted(account.Username())
|
||||
defer ctx.MessagePreparationFinished(account.Username())
|
||||
|
||||
labelIDs, err := ctx.GetPMAPIController().GetLabelIDs(account.Username(), strings.Split(mailboxNames, ","))
|
||||
if err != nil {
|
||||
return internalError(err, "getting labels %s for %s", mailboxNames, account.Username())
|
||||
@ -100,9 +101,10 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd
|
||||
for i := len(messages.Rows) - 1; i > 0; i-- {
|
||||
row := messages.Rows[i]
|
||||
message := &pmapi.Message{
|
||||
MIMEType: pmapi.ContentTypePlainText,
|
||||
LabelIDs: labelIDs,
|
||||
AddressID: account.AddressID(),
|
||||
MIMEType: pmapi.ContentTypePlainText,
|
||||
LabelIDs: labelIDs,
|
||||
AddressID: account.AddressID(),
|
||||
ExternalID: fmt.Sprintf("%d@integration.setup.test", time.Now().Unix()),
|
||||
}
|
||||
header := make(textproto.MIMEHeader)
|
||||
|
||||
@ -275,30 +277,31 @@ func processMailboxStructureDataTable(structure *godog.Table, callback func(stri
|
||||
}
|
||||
|
||||
func thereAreSomeMessagesInMailboxesForAddressOfUser(numberOfMessages int, mailboxNames, bddAddressID, bddUserID string) error {
|
||||
// It is needed to prevent event processing before syncing these message
|
||||
// otherwise the seqID and UID will be in reverse order. The
|
||||
// synchronization add newest message first, the eventloop adds the oldest
|
||||
// message first.
|
||||
ctx.MessagePreparationStarted()
|
||||
defer ctx.MessagePreparationFinished()
|
||||
|
||||
account := ctx.GetTestAccountWithAddress(bddUserID, bddAddressID)
|
||||
if account == nil {
|
||||
return godog.ErrPending
|
||||
}
|
||||
|
||||
// It is needed to prevent event processing before syncing these message
|
||||
// otherwise the seqID and UID will be in reverse order. The
|
||||
// synchronization add newest message first, the eventloop adds the oldest
|
||||
// message first.
|
||||
ctx.MessagePreparationStarted(account.Username())
|
||||
defer ctx.MessagePreparationFinished(account.Username())
|
||||
|
||||
for i := 1; i <= numberOfMessages; i++ {
|
||||
labelIDs, err := ctx.GetPMAPIController().GetLabelIDs(account.Username(), strings.Split(mailboxNames, ","))
|
||||
if err != nil {
|
||||
return internalError(err, "getting labels %s for %s", mailboxNames, account.Username())
|
||||
}
|
||||
lastMessageID, err := ctx.GetPMAPIController().AddUserMessage(account.Username(), &pmapi.Message{
|
||||
MIMEType: "text/plain",
|
||||
LabelIDs: labelIDs,
|
||||
AddressID: account.AddressID(),
|
||||
Subject: fmt.Sprintf("Test message #%d", i),
|
||||
Sender: &mail.Address{Address: "anyone@example.com"},
|
||||
ToList: []*mail.Address{{Address: account.Address()}},
|
||||
MIMEType: "text/plain",
|
||||
LabelIDs: labelIDs,
|
||||
AddressID: account.AddressID(),
|
||||
Subject: fmt.Sprintf("Test message #%d", i),
|
||||
Sender: &mail.Address{Address: "anyone@example.com"},
|
||||
ToList: []*mail.Address{{Address: account.Address()}},
|
||||
ExternalID: fmt.Sprintf("%d@integration.setup.test", time.Now().Unix()),
|
||||
})
|
||||
if err != nil {
|
||||
return internalError(err, "adding message")
|
||||
@ -311,3 +314,8 @@ func thereAreSomeMessagesInMailboxesForAddressOfUser(numberOfMessages int, mailb
|
||||
}
|
||||
return internalError(ctx.WaitForSync(account.Username()), "waiting for sync")
|
||||
}
|
||||
|
||||
func waitForSphinx() error {
|
||||
time.Sleep(15 * time.Second)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user