mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 15:46:44 +00:00
test - move like outlook - GODT-536
This commit is contained in:
@ -19,6 +19,7 @@ package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/gherkin"
|
||||
@ -32,6 +33,7 @@ func IMAPActionsMessagesFeatureContext(s *godog.Suite) {
|
||||
s.Step(`^IMAP client searches for "([^"]*)"$`, imapClientSearchesFor)
|
||||
s.Step(`^IMAP client copies messages "([^"]*)" to "([^"]*)"$`, imapClientCopiesMessagesTo)
|
||||
s.Step(`^IMAP client moves messages "([^"]*)" to "([^"]*)"$`, imapClientMovesMessagesTo)
|
||||
s.Step(`^IMAP client moves messages "([^"]*)" to "([^"]*)" like outlook$`, imapClientMovesMessagesToLikeOutlook)
|
||||
s.Step(`^IMAP client imports message to "([^"]*)"$`, imapClientCreatesMessage)
|
||||
s.Step(`^IMAP client imports message to "([^"]*)" with encoding "([^"]*)"$`, imapClientCreatesMessageWithEncoding)
|
||||
s.Step(`^IMAP client creates message "([^"]*)" from "([^"]*)" to "([^"]*)" with body "([^"]*)" in "([^"]*)"$`, imapClientCreatesMessageFromToWithBody)
|
||||
@ -93,6 +95,47 @@ func imapClientMovesMessagesTo(messageRange, newMailboxName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func imapClientMovesMessagesToLikeOutlook(messageRange, newMailboxName, user string) error {
|
||||
sourceClient := "imap"
|
||||
fetchResp := ctx.GetIMAPClient(sourceClient).Fetch(messageRange, "body.peek[]")
|
||||
fetchResp.AssertOK()
|
||||
if err := ctx.GetTestingError(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
targetClient := "target"
|
||||
if err := thereIsIMAPClientNamedLoggedInAs(targetClient, user); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := thereIsIMAPClientNamedSelectedIn(targetClient, newMailboxName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
movingLikeOutlook := sync.WaitGroup{}
|
||||
movingLikeOutlook.Add(2)
|
||||
|
||||
go func() {
|
||||
defer movingLikeOutlook.Done()
|
||||
for _, msg := range fetchResp.Sections() {
|
||||
res := ctx.GetIMAPClient(targetClient).Append(newMailboxName, msg)
|
||||
res.AssertOK()
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer movingLikeOutlook.Done()
|
||||
imapClientNamedMarksMessageAsDeleted(sourceClient, messageRange)
|
||||
ctx.GetIMAPLastResponse(sourceClient).AssertOK()
|
||||
}()
|
||||
|
||||
movingLikeOutlook.Wait()
|
||||
|
||||
imapClientExpunge()
|
||||
ctx.GetIMAPLastResponse(sourceClient).AssertOK()
|
||||
|
||||
return ctx.GetTestingError()
|
||||
}
|
||||
|
||||
func imapClientCreatesMessage(mailboxName string, message *gherkin.DocString) error {
|
||||
return imapClientCreatesMessageWithEncoding(mailboxName, "utf8", message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user