OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package mail |
| 6 |
| 7 // TestMessage is the message struct which will be returned from SentMessages. |
| 8 // |
| 9 // It augments the Message struct by also including the derived MIMEType for any |
| 10 // attachments. |
| 11 type TestMessage struct { |
| 12 Message |
| 13 |
| 14 // MIMETypes is guaranteed to be the same length as the attachments in t
he |
| 15 // Message, and will be populated with the derived MIME types for the |
| 16 // attachments. |
| 17 MIMETypes []string |
| 18 } |
| 19 |
| 20 // Copy duplicates this TestMessage. |
| 21 func (t *TestMessage) Copy() *TestMessage { |
| 22 if t == nil { |
| 23 return nil |
| 24 } |
| 25 ret := &TestMessage{Message: *t.Message.Copy()} |
| 26 if len(t.MIMETypes) > 0 { |
| 27 ret.MIMETypes = make([]string, len(t.MIMETypes)) |
| 28 copy(ret.MIMETypes, t.MIMETypes) |
| 29 } |
| 30 return ret |
| 31 } |
| 32 |
| 33 // Testable is the interface for mail service implementations which are able |
| 34 // to be tested (like impl/memory). |
| 35 type Testable interface { |
| 36 // Sets the list of admin emails. By default, testing implementations sh
ould |
| 37 // use ["admin@example.com"]. |
| 38 SetAdminEmails(emails ...string) |
| 39 |
| 40 // SentMessages returns a copy of all messages which were successfully s
ent |
| 41 // via the mail API. |
| 42 SentMessages() []*TestMessage |
| 43 |
| 44 // Reset clears the SentMessages queue. |
| 45 Reset() |
| 46 } |
OLD | NEW |