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

Unified Diff: service/mail/message_test.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.go ('k') | service/mail/testable.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/mail/message_test.go
diff --git a/service/mail/message_test.go b/service/mail/message_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..da0f1cfb11b58e7f70ca70875f05fa321c2e528a
--- /dev/null
+++ b/service/mail/message_test.go
@@ -0,0 +1,88 @@
+// 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
+
+import (
+ net_mail "net/mail"
+ "testing"
+
+ . "github.com/luci/luci-go/common/testing/assertions"
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestDataTypes(t *testing.T) {
+ t.Parallel()
+
+ Convey("data types", t, func() {
+ m := &Message{
+ "from@example.com",
+ "reply_to@example.com",
+ []string{"to1@example.com", "to2@example.com"},
+ []string{"cc1@example.com", "cc2@example.com"},
+ []string{"bcc1@example.com", "bcc2@example.com"},
+ "subject",
+ "body",
+ "<html><body>body</body></html>",
+ []Attachment{{"name.doc", []byte("data"), "https://content_id"}},
+ net_mail.Header{
+ "In-Reply-To": []string{"cats"},
+ },
+ }
+
+ Convey("empty copy doesn't do extra allocations", func() {
+ m := (&Message{}).Copy()
+ So(m.To, ShouldBeNil)
+ So(m.Cc, ShouldBeNil)
+ So(m.Bcc, ShouldBeNil)
+ So(m.Attachments, ShouldBeNil)
+ So(m.Headers, ShouldBeNil)
+
+ tm := (&TestMessage{}).Copy()
+ So(tm.MIMETypes, ShouldBeNil)
+ })
+
+ Convey("can copy nil", func() {
+ So((*Message)(nil).Copy(), ShouldBeNil)
+ So((*Message)(nil).ToSDKMessage(), ShouldBeNil)
+ So((*TestMessage)(nil).Copy(), ShouldBeNil)
+ })
+
+ Convey("Message is copyable", func() {
+ m2 := m.Copy()
+ So(m2, ShouldResembleV, m)
+
+ // make sure it's really a copy
+ m2.To[0] = "fake@faker.example.com"
+ So(m2.To, ShouldNotResembleV, m.To)
+
+ m2.Headers["SomethingElse"] = []string{"noooo"}
+ So(m2.Headers, ShouldNotResembleV, m.Headers)
+ })
+
+ Convey("TestMessage is copyable", func() {
+ tm := &TestMessage{*m, []string{"application/msword"}}
+ tm2 := tm.Copy()
+ So(tm, ShouldResembleV, tm2)
+
+ tm2.MIMETypes[0] = "spam"
+ So(tm, ShouldNotResembleV, tm2)
+ })
+
+ Convey("Message can be cast to an SDK Message", func() {
+ m2 := m.ToSDKMessage()
+ So(m2.Sender, ShouldResembleV, m.Sender)
+ So(m2.ReplyTo, ShouldResembleV, m.ReplyTo)
+ So(m2.To, ShouldResembleV, m.To)
+ So(m2.Cc, ShouldResembleV, m.Cc)
+ So(m2.Bcc, ShouldResembleV, m.Bcc)
+ So(m2.Subject, ShouldResembleV, m.Subject)
+ So(m2.Body, ShouldResembleV, m.Body)
+ So(m2.HTMLBody, ShouldResembleV, m.HTMLBody)
+ So(m2.Headers, ShouldResembleV, m.Headers)
+
+ So((Attachment)(m2.Attachments[0]), ShouldResembleV, m.Attachments[0])
+ })
+ })
+}
« no previous file with comments | « service/mail/message.go ('k') | service/mail/testable.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698