test: step definitions changed

This commit is contained in:
Jakub
2023-02-15 14:44:27 +01:00
3 changed files with 11 additions and 8 deletions

View File

@ -36,7 +36,6 @@ import (
"github.com/ProtonMail/proton-bridge/v3/internal/vault" "github.com/ProtonMail/proton-bridge/v3/internal/vault"
"github.com/bradenaw/juniper/parallel" "github.com/bradenaw/juniper/parallel"
"github.com/bradenaw/juniper/xslices" "github.com/bradenaw/juniper/xslices"
"github.com/google/uuid"
"github.com/pbnjay/memory" "github.com/pbnjay/memory"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/exp/maps" "golang.org/x/exp/maps"
@ -59,6 +58,7 @@ func (user *User) syncSystemLabels(ctx context.Context) error {
updates = append(updates, update) updates = append(updates, update)
} }
} }
if err := waitOnIMAPUpdates(ctx, updates); err != nil { if err := waitOnIMAPUpdates(ctx, updates); err != nil {
return fmt.Errorf("could not sync system labels: %w", err) return fmt.Errorf("could not sync system labels: %w", err)
} }
@ -187,7 +187,7 @@ func (user *User) sync(ctx context.Context) error {
func syncLabels(ctx context.Context, apiLabels map[string]proton.Label, updateCh ...*queue.QueuedChannel[imap.Update]) error { func syncLabels(ctx context.Context, apiLabels map[string]proton.Label, updateCh ...*queue.QueuedChannel[imap.Update]) error {
var updates []imap.Update var updates []imap.Update
// Create placeholder Folders/Labels mailboxes with a random ID and with the \Noselect attribute. // Create placeholder Folders/Labels mailboxes with the \Noselect attribute.
for _, prefix := range []string{folderPrefix, labelPrefix} { for _, prefix := range []string{folderPrefix, labelPrefix} {
for _, updateCh := range updateCh { for _, updateCh := range updateCh {
update := newPlaceHolderMailboxCreatedUpdate(prefix) update := newPlaceHolderMailboxCreatedUpdate(prefix)
@ -698,7 +698,7 @@ func newSystemMailboxCreatedUpdate(labelID imap.MailboxID, labelName string) *im
func newPlaceHolderMailboxCreatedUpdate(labelName string) *imap.MailboxCreated { func newPlaceHolderMailboxCreatedUpdate(labelName string) *imap.MailboxCreated {
return imap.NewMailboxCreated(imap.Mailbox{ return imap.NewMailboxCreated(imap.Mailbox{
ID: imap.MailboxID(uuid.NewString()), ID: imap.MailboxID(labelName),
Name: []string{labelName}, Name: []string{labelName},
Flags: defaultFlags, Flags: defaultFlags,
PermanentFlags: defaultPermanentFlags, PermanentFlags: defaultPermanentFlags,

View File

@ -191,11 +191,14 @@ func New(
user.syncAbort.Do(ctx, func(ctx context.Context) { user.syncAbort.Do(ctx, func(ctx context.Context) {
if user.vault.SyncStatus().IsComplete() { if user.vault.SyncStatus().IsComplete() {
user.log.Info("Sync already complete, only system label will be updated") user.log.Info("Sync already complete, only system label will be updated")
if err := user.syncSystemLabels(ctx); err != nil { if err := user.syncSystemLabels(ctx); err != nil {
user.log.WithError(err).Error("Failed to update system labels") user.log.WithError(err).Error("Failed to update system labels")
return return
} }
user.log.Info("System label update complete, starting API event stream") user.log.Info("System label update complete, starting API event stream")
return return
} }

View File

@ -93,23 +93,23 @@ Feature: IMAP move messages
Scenario: Move message from system label to system label Scenario: Move message from system label to system label
When IMAP client "1" moves the message with subject "foo" from "INBOX" to "Trash" When IMAP client "1" moves the message with subject "foo" from "INBOX" to "Trash"
And it succeeds And it succeeds
And IMAP client "1" sees the following messages in "INBOX": And IMAP client "1" eventually sees the following messages in "INBOX":
| from | to | subject | unread | | from | to | subject | unread |
| jane.doe@mail.com | name@[domain] | bar | true | | jane.doe@mail.com | name@[domain] | bar | true |
And IMAP client "1" sees the following messages in "Trash": And IMAP client "1" eventually sees the following messages in "Trash":
| from | to | subject | unread | | from | to | subject | unread |
| john.doe@mail.com | [user:user]@[domain] | foo | false | | john.doe@mail.com | [user:user]@[domain] | foo | false |
Scenario: Move message from folder to system label Scenario: Move message from folder to system label
When IMAP client "1" moves the message with subject "baz" from "Labels/label2" to "Folders/mbox" When IMAP client "1" moves the message with subject "baz" from "Labels/label2" to "Folders/mbox"
And it succeeds And it succeeds
And IMAP client "1" sees the following messages in "Folders/mbox": And IMAP client "1" eventually sees the following messages in "Folders/mbox":
| from | to | subject | unread | | from | to | subject | unread |
| john.doe@mail.com | [user:user]@[domain] | baz | false | | john.doe@mail.com | [user:user]@[domain] | baz | false |
When IMAP client "1" moves the message with subject "baz" from "Folders/mbox" to "Trash" When IMAP client "1" moves the message with subject "baz" from "Folders/mbox" to "Trash"
And it succeeds And it succeeds
And IMAP client "1" sees 0 messages in "Folders/mbox" And IMAP client "1" eventually sees 0 messages in "Folders/mbox"
And IMAP client "1" sees the following messages in "Trash": And IMAP client "1" eventually sees the following messages in "Trash":
| from | to | subject | unread | | from | to | subject | unread |
| john.doe@mail.com | [user:user]@[domain] | baz | false | | john.doe@mail.com | [user:user]@[domain] | baz | false |