Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: service/mail/testable.go

Issue 1525923002: Implement Mail service. (Closed) Base URL: https://github.com/luci/gae.git@filter_user
Patch Set: tests and words Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « service/mail/message_test.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/mail/testable.go
diff --git a/service/mail/testable.go b/service/mail/testable.go
new file mode 100644
index 0000000000000000000000000000000000000000..367dfdc1eec424950fba20d5e38ec38c31ce919b
--- /dev/null
+++ b/service/mail/testable.go
@@ -0,0 +1,46 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package mail
+
+// TestMessage is the message struct which will be returned from SentMessages.
+//
+// It augments the Message struct by also including the derived MIMEType for any
+// attachments.
+type TestMessage struct {
+ Message
+
+ // MIMETypes is guaranteed to be the same length as the attachments in the
+ // Message, and will be populated with the derived MIME types for the
+ // attachments.
+ MIMETypes []string
+}
+
+// Copy duplicates this TestMessage.
+func (t *TestMessage) Copy() *TestMessage {
+ if t == nil {
+ return nil
+ }
+ ret := &TestMessage{Message: *t.Message.Copy()}
+ if len(t.MIMETypes) > 0 {
+ ret.MIMETypes = make([]string, len(t.MIMETypes))
+ copy(ret.MIMETypes, t.MIMETypes)
+ }
+ return ret
+}
+
+// Testable is the interface for mail service implementations which are able
+// to be tested (like impl/memory).
+type Testable interface {
+ // Sets the list of admin emails. By default, testing implementations should
+ // use ["admin@example.com"].
+ SetAdminEmails(emails ...string)
+
+ // SentMessages returns a copy of all messages which were successfully sent
+ // via the mail API.
+ SentMessages() []*TestMessage
+
+ // Reset clears the SentMessages queue.
+ Reset()
+}
« no previous file with comments | « service/mail/message_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698