GODT-1499: Remove message from DB once is not on server any more

This commit is contained in:
Jakub
2022-01-18 18:23:00 +01:00
committed by Jakub Cuth
parent a3d2df9d38
commit 8e0693ab03
9 changed files with 107 additions and 5 deletions

View File

@ -38,6 +38,7 @@ func StoreSetupFeatureContext(s *godog.ScenarioContext) {
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)
s.Step(`^message(?:s)? "([^"]*)" (?:was|were) deleted forever without event processed for "([^"]*)"$`, messageWasDeletedWithoutEvent)
}
func thereIsUserWithMailboxes(bddUserID string, mailboxes *godog.Table) error {
@ -319,3 +320,16 @@ func waitForSphinx() error {
time.Sleep(15 * time.Second)
return nil
}
func messageWasDeletedWithoutEvent(bddMessageID, bddUserID string) error {
account := ctx.GetTestAccount(bddUserID)
if account == nil {
return godog.ErrPending
}
apiID, err := ctx.GetAPIMessageID(account.Username(), bddMessageID)
if err != nil {
return internalError(err, "getting BDD message ID %s", bddMessageID)
}
return ctx.GetPMAPIController().RemoveUserMessageWithoutEvent(account.Username(), apiID)
}