GODT-1055 Fix flaky empty trash test

This commit is contained in:
Michal Horejsek
2021-02-22 12:43:45 +01:00
parent b27e3fdb28
commit f499252444

View File

@ -18,6 +18,8 @@
package tests package tests
import ( import (
"time"
"github.com/cucumber/godog" "github.com/cucumber/godog"
) )
@ -44,6 +46,16 @@ func imapClientRenamesMailboxTo(mailboxName, newMailboxName string) error {
} }
func imapClientDeletesMailbox(mailboxName string) error { func imapClientDeletesMailbox(mailboxName string) error {
if mailboxName == "Trash" {
// Delete of Trash mailbox calls empty label on API.
// Empty label means delete all messages in that label with time
// creation before time of execution. But creation time is in
// seconds, not miliseconds. That's why message created at the
// same second as emptying label is called is not deleted.
// Tests might be that fast and therefore we need to sleep for
// a second to make sure test doesn't produce fake failure.
time.Sleep(time.Second)
}
res := ctx.GetIMAPClient("imap").DeleteMailbox(mailboxName) res := ctx.GetIMAPClient("imap").DeleteMailbox(mailboxName)
ctx.SetIMAPLastResponse("imap", res) ctx.SetIMAPLastResponse("imap", res)
return nil return nil