mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 07:36:44 +00:00
Fixes after rebase
This commit is contained in:
@ -103,7 +103,7 @@ func apiMailboxForAddressOfUserHasMessages(mailboxName, bddAddressID, bddUserID
|
||||
|
||||
head := messages.Rows[0].Cells
|
||||
for _, row := range messages.Rows[1:] {
|
||||
found, err := messagesContainsMessageRow(account, pmapiMessages, head, row)
|
||||
found, err := pmapiMessagesContainsMessageRow(account, pmapiMessages, head, row)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -161,3 +161,4 @@ func (ctl *Controller) GetMessages(username, labelID string) ([]*pmapi.Message,
|
||||
}
|
||||
|
||||
return messages, nil
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ type IMAPResponse struct {
|
||||
done bool
|
||||
}
|
||||
|
||||
func (ir *IMAPResponse) sendCommand(reqTag string, reqIndex int, command string, debug *debug, conn io.Writer, response *bufio.Reader) {
|
||||
func (ir *IMAPResponse) sendCommand(reqTag string, reqIndex int, command string, debug *debug, conn io.Writer, response *bufio.Reader) { //nolint[interfacer]
|
||||
defer func() { ir.done = true }()
|
||||
|
||||
tstart := time.Now()
|
||||
|
||||
@ -24,6 +24,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/store"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
"github.com/ProtonMail/proton-bridge/test/accounts"
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/gherkin"
|
||||
@ -143,7 +144,7 @@ func mailboxForAddressOfUserHasMessages(mailboxName, bddAddressID, bddUserID str
|
||||
afterLimit := time.Since(start) > ctx.EventLoopTimeout()
|
||||
allFound := true
|
||||
for _, row := range messages.Rows[1:] {
|
||||
found, err := messagesContainsMessageRow(account, allMessages, head, row)
|
||||
found, err := storeMessagesContainsMessageRow(account, allMessages, head, row)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -168,10 +169,36 @@ func mailboxForAddressOfUserHasMessages(mailboxName, bddAddressID, bddUserID str
|
||||
return nil
|
||||
}
|
||||
|
||||
func messagesContainsMessageRow(account *accounts.TestAccount, allMessages []*store.Message, head []*gherkin.TableCell, row *gherkin.TableRow) (bool, error) { //nolint[funlen]
|
||||
func pmapiMessagesContainsMessageRow(account *accounts.TestAccount, pmapiMessages []*pmapi.Message, head []*gherkin.TableCell, row *gherkin.TableRow) (bool, error) {
|
||||
messages := make([]interface{}, len(pmapiMessages))
|
||||
for i := range pmapiMessages {
|
||||
messages[i] = pmapiMessages[i]
|
||||
}
|
||||
return messagesContainsMessageRow(account, messages, head, row)
|
||||
}
|
||||
|
||||
func storeMessagesContainsMessageRow(account *accounts.TestAccount, storeMessages []*store.Message, head []*gherkin.TableCell, row *gherkin.TableRow) (bool, error) {
|
||||
messages := make([]interface{}, len(storeMessages))
|
||||
for i := range storeMessages {
|
||||
messages[i] = storeMessages[i]
|
||||
}
|
||||
return messagesContainsMessageRow(account, messages, head, row)
|
||||
}
|
||||
|
||||
func messagesContainsMessageRow(account *accounts.TestAccount, allMessages []interface{}, head []*gherkin.TableCell, row *gherkin.TableRow) (bool, error) { //nolint[funlen]
|
||||
found := false
|
||||
for _, storeMessage := range allMessages {
|
||||
message := storeMessage.Message()
|
||||
for _, someMessage := range allMessages {
|
||||
var message *pmapi.Message
|
||||
var storeMessage *store.Message
|
||||
|
||||
switch v := someMessage.(type) {
|
||||
case *pmapi.Message:
|
||||
message = v
|
||||
case *store.Message:
|
||||
message = v.Message()
|
||||
storeMessage = v
|
||||
}
|
||||
|
||||
matches := true
|
||||
for n, cell := range row.Cells {
|
||||
switch head[n].Value {
|
||||
@ -221,6 +248,10 @@ func messagesContainsMessageRow(account *accounts.TestAccount, allMessages []*st
|
||||
matches = false
|
||||
}
|
||||
case "deleted":
|
||||
if storeMessage == nil {
|
||||
return false, fmt.Errorf("deleted column not supported for pmapi message object")
|
||||
}
|
||||
|
||||
expectedDeleted := cell.Value == "true"
|
||||
matches = storeMessage.IsMarkedDeleted() == expectedDeleted
|
||||
default:
|
||||
|
||||
@ -157,6 +157,7 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd
|
||||
return err
|
||||
}
|
||||
|
||||
if len(markMessageIDsDeleted) > 0 {
|
||||
for _, mailboxName := range strings.Split(mailboxNames, ",") {
|
||||
storeMailbox, err := ctx.GetStoreMailbox(account.Username(), account.AddressID(), mailboxName)
|
||||
if err != nil {
|
||||
@ -166,6 +167,7 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user