mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 13:16:53 +00:00
GODT-2170: Use client-side draft update in integration tests
This commit is contained in:
@ -230,36 +230,28 @@ func (t *testCtx) getMBoxID(userID string, name string) string {
|
||||
// getDraftID will return the API ID of draft message with draftIndex, where
|
||||
// draftIndex is similar to sequential ID i.e. 1 represents the first message
|
||||
// of draft folder sorted by API creation time.
|
||||
func (t *testCtx) getDraftID(username string, draftIndex int) string {
|
||||
if draftIndex < 1 {
|
||||
panic(fmt.Sprintf("draft index suppose to be non-zero positive integer, but have %d", draftIndex))
|
||||
}
|
||||
|
||||
func (t *testCtx) getDraftID(username string, draftIndex int) (string, error) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
var draftID string
|
||||
|
||||
if err := t.withClient(ctx, username, func(ctx context.Context, client *proton.Client) error {
|
||||
messages, err := client.GetMessageMetadata(
|
||||
ctx, proton.MessageFilter{LabelID: proton.DraftsLabel},
|
||||
)
|
||||
messages, err := client.GetMessageMetadata(ctx, proton.MessageFilter{LabelID: proton.DraftsLabel})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if len(messages) < draftIndex {
|
||||
panic("draft index too high")
|
||||
return fmt.Errorf("failed to get message metadata: %w", err)
|
||||
} else if len(messages) < draftIndex {
|
||||
return fmt.Errorf("draft index %d is out of range", draftIndex)
|
||||
}
|
||||
|
||||
draftID = messages[draftIndex-1].ID
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
return draftID
|
||||
return draftID, nil
|
||||
}
|
||||
|
||||
func (t *testCtx) getLastCall(method, pathExp string) (server.Call, error) {
|
||||
|
||||
Reference in New Issue
Block a user