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

Side by Side Diff: impl/memory/mail_test.go

Issue 1679093002: Use ShouldResemble instead of ShouldResembleV. (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: Created 4 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « impl/memory/datastore_query_execution_test.go ('k') | impl/memory/user_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package memory 5 package memory
6 6
7 import ( 7 import (
8 net_mail "net/mail" 8 net_mail "net/mail"
9 "testing" 9 "testing"
10 10
(...skipping 19 matching lines...) Expand all
30 30
31 Convey("can send a message from the admin", func() { 31 Convey("can send a message from the admin", func() {
32 So(mail.Send(&mailS.Message{ 32 So(mail.Send(&mailS.Message{
33 Sender: "admin@example.com", 33 Sender: "admin@example.com",
34 To: []string{"Valued Customer <cust omer@example.com>"}, 34 To: []string{"Valued Customer <cust omer@example.com>"},
35 Subject: "You are valued.", 35 Subject: "You are valued.",
36 Body: "We value you.", 36 Body: "We value you.",
37 }), ShouldBeNil) 37 }), ShouldBeNil)
38 38
39 Convey("and it shows up in sent messages", func( ) { 39 Convey("and it shows up in sent messages", func( ) {
40 » » » » » So(mail.Testable().SentMessages(), Shoul dResembleV, []*mailS.TestMessage{ 40 » » » » » So(mail.Testable().SentMessages(), Shoul dResemble, []*mailS.TestMessage{
41 {Message: mailS.Message{ 41 {Message: mailS.Message{
42 Sender: "admin@example. com", 42 Sender: "admin@example. com",
43 To: []string{"Value d Customer <customer@example.com>"}, 43 To: []string{"Value d Customer <customer@example.com>"},
44 Subject: "You are valued .", 44 Subject: "You are valued .",
45 Body: "We value you." , 45 Body: "We value you." ,
46 }}, 46 }},
47 }) 47 })
48 48
49 Convey("which can be reset", func() { 49 Convey("which can be reset", func() {
50 mail.Testable().Reset() 50 mail.Testable().Reset()
(...skipping 12 matching lines...) Expand all
63 }), ShouldBeNil) 63 }), ShouldBeNil)
64 }) 64 })
65 65
66 Convey("can send a message to the admins", func() { 66 Convey("can send a message to the admins", func() {
67 So(mail.SendToAdmins(&mailS.Message{ 67 So(mail.SendToAdmins(&mailS.Message{
68 Sender: "admin@example.com", 68 Sender: "admin@example.com",
69 Subject: "Reminder", 69 Subject: "Reminder",
70 Body: "I forgot", 70 Body: "I forgot",
71 }), ShouldBeNil) 71 }), ShouldBeNil)
72 72
73 » » » » So(mail.Testable().SentMessages(), ShouldResembl eV, []*mailS.TestMessage{ 73 » » » » So(mail.Testable().SentMessages(), ShouldResembl e, []*mailS.TestMessage{
74 {Message: mailS.Message{ 74 {Message: mailS.Message{
75 Sender: "admin@example.com", 75 Sender: "admin@example.com",
76 To: []string{"admin@example .com"}, 76 To: []string{"admin@example .com"},
77 Subject: "Reminder", 77 Subject: "Reminder",
78 Body: "I forgot", 78 Body: "I forgot",
79 }}, 79 }},
80 }) 80 })
81 }) 81 })
82 82
83 Convey("can set admin emails", func() { 83 Convey("can set admin emails", func() {
84 mail.Testable().SetAdminEmails( 84 mail.Testable().SetAdminEmails(
85 "Friendly <hello@example.com>", 85 "Friendly <hello@example.com>",
86 "Epic <nerdsnipe@example.com>", 86 "Epic <nerdsnipe@example.com>",
87 ) 87 )
88 88
89 So(mail.SendToAdmins(&mailS.Message{ 89 So(mail.SendToAdmins(&mailS.Message{
90 Sender: "hello@example.com", 90 Sender: "hello@example.com",
91 Subject: "Reminder", 91 Subject: "Reminder",
92 Body: "I forgot", 92 Body: "I forgot",
93 }), ShouldBeNil) 93 }), ShouldBeNil)
94 94
95 » » » » So(mail.Testable().SentMessages(), ShouldResembl eV, []*mailS.TestMessage{ 95 » » » » So(mail.Testable().SentMessages(), ShouldResembl e, []*mailS.TestMessage{
96 {Message: mailS.Message{ 96 {Message: mailS.Message{
97 Sender: "hello@example.com", 97 Sender: "hello@example.com",
98 To: []string{ 98 To: []string{
99 "Friendly <hello@example .com>", 99 "Friendly <hello@example .com>",
100 "Epic <nerdsnipe@example .com>", 100 "Epic <nerdsnipe@example .com>",
101 }, 101 },
102 Subject: "Reminder", 102 Subject: "Reminder",
103 Body: "I forgot", 103 Body: "I forgot",
104 }}, 104 }},
105 }) 105 })
106 }) 106 })
107 107
108 Convey("attachments get mimetypes assigned to them", fun c() { 108 Convey("attachments get mimetypes assigned to them", fun c() {
109 So(mail.SendToAdmins(&mailS.Message{ 109 So(mail.SendToAdmins(&mailS.Message{
110 Sender: "admin@example.com", 110 Sender: "admin@example.com",
111 Subject: "Reminder", 111 Subject: "Reminder",
112 Body: "I forgot", 112 Body: "I forgot",
113 Attachments: []mailS.Attachment{ 113 Attachments: []mailS.Attachment{
114 {Name: "reminder.txt", Data: []b yte("bananas")}, 114 {Name: "reminder.txt", Data: []b yte("bananas")},
115 {Name: "coolthing", Data: []byte ("bananas")}, 115 {Name: "coolthing", Data: []byte ("bananas")},
116 }, 116 },
117 }), ShouldBeNil) 117 }), ShouldBeNil)
118 118
119 » » » » So(mail.Testable().SentMessages(), ShouldResembl eV, []*mailS.TestMessage{ 119 » » » » So(mail.Testable().SentMessages(), ShouldResembl e, []*mailS.TestMessage{
120 { 120 {
121 Message: mailS.Message{ 121 Message: mailS.Message{
122 Sender: "admin@example. com", 122 Sender: "admin@example. com",
123 To: []string{"admin @example.com"}, 123 To: []string{"admin @example.com"},
124 Subject: "Reminder", 124 Subject: "Reminder",
125 Body: "I forgot", 125 Body: "I forgot",
126 Attachments: []mailS.Att achment{ 126 Attachments: []mailS.Att achment{
127 {Name: "reminder .txt", Data: []byte("bananas")}, 127 {Name: "reminder .txt", Data: []byte("bananas")},
128 {Name: "coolthin g", Data: []byte("bananas")}, 128 {Name: "coolthin g", Data: []byte("bananas")},
129 }, 129 },
130 }, 130 },
131 MIMETypes: []string{"text/plain" , "application/octet-stream"}}, 131 MIMETypes: []string{"text/plain" , "application/octet-stream"}},
132 }) 132 })
133 }) 133 })
134 134
135 Convey("can have headers", func() { 135 Convey("can have headers", func() {
136 So(mail.SendToAdmins(&mailS.Message{ 136 So(mail.SendToAdmins(&mailS.Message{
137 Sender: "admin@example.com", 137 Sender: "admin@example.com",
138 Subject: "Reminder", 138 Subject: "Reminder",
139 Body: "I forgot", 139 Body: "I forgot",
140 Headers: net_mail.Header{ 140 Headers: net_mail.Header{
141 "in-reply-to": []string{"epicnes s"}, 141 "in-reply-to": []string{"epicnes s"},
142 "List-Id": []string{"spam"}, 142 "List-Id": []string{"spam"},
143 }, 143 },
144 }), ShouldBeNil) 144 }), ShouldBeNil)
145 145
146 » » » » So(mail.Testable().SentMessages(), ShouldResembl eV, []*mailS.TestMessage{ 146 » » » » So(mail.Testable().SentMessages(), ShouldResembl e, []*mailS.TestMessage{
147 {Message: mailS.Message{ 147 {Message: mailS.Message{
148 Sender: "admin@example.com", 148 Sender: "admin@example.com",
149 To: []string{"admin@example .com"}, 149 To: []string{"admin@example .com"},
150 Subject: "Reminder", 150 Subject: "Reminder",
151 Body: "I forgot", 151 Body: "I forgot",
152 Headers: net_mail.Header{ 152 Headers: net_mail.Header{
153 "In-Reply-To": []string{ "epicness"}, 153 "In-Reply-To": []string{ "epicness"},
154 "List-Id": []string{ "spam"}, 154 "List-Id": []string{ "spam"},
155 }, 155 },
156 }}, 156 }},
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 Body: "I forgot", 229 Body: "I forgot",
230 Headers: net_mail.Header{"x-spam-cool": []string{"value"}}, 230 Headers: net_mail.Header{"x-spam-cool": []string{"value"}},
231 }), ShouldErrLike, `disallowed header: x-spam-co ol`) 231 }), ShouldErrLike, `disallowed header: x-spam-co ol`)
232 232
233 }) 233 })
234 234
235 }) 235 })
236 236
237 }) 237 })
238 } 238 }
OLDNEW
« no previous file with comments | « impl/memory/datastore_query_execution_test.go ('k') | impl/memory/user_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698