OLD | NEW |
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 mail | 5 package mail |
6 | 6 |
7 import ( | 7 import ( |
8 net_mail "net/mail" | 8 net_mail "net/mail" |
9 "testing" | 9 "testing" |
10 | 10 |
11 . "github.com/luci/luci-go/common/testing/assertions" | |
12 . "github.com/smartystreets/goconvey/convey" | 11 . "github.com/smartystreets/goconvey/convey" |
13 ) | 12 ) |
14 | 13 |
15 func TestDataTypes(t *testing.T) { | 14 func TestDataTypes(t *testing.T) { |
16 t.Parallel() | 15 t.Parallel() |
17 | 16 |
18 Convey("data types", t, func() { | 17 Convey("data types", t, func() { |
19 m := &Message{ | 18 m := &Message{ |
20 "from@example.com", | 19 "from@example.com", |
21 "reply_to@example.com", | 20 "reply_to@example.com", |
(...skipping 22 matching lines...) Expand all Loading... |
44 }) | 43 }) |
45 | 44 |
46 Convey("can copy nil", func() { | 45 Convey("can copy nil", func() { |
47 So((*Message)(nil).Copy(), ShouldBeNil) | 46 So((*Message)(nil).Copy(), ShouldBeNil) |
48 So((*Message)(nil).ToSDKMessage(), ShouldBeNil) | 47 So((*Message)(nil).ToSDKMessage(), ShouldBeNil) |
49 So((*TestMessage)(nil).Copy(), ShouldBeNil) | 48 So((*TestMessage)(nil).Copy(), ShouldBeNil) |
50 }) | 49 }) |
51 | 50 |
52 Convey("Message is copyable", func() { | 51 Convey("Message is copyable", func() { |
53 m2 := m.Copy() | 52 m2 := m.Copy() |
54 » » » So(m2, ShouldResembleV, m) | 53 » » » So(m2, ShouldResemble, m) |
55 | 54 |
56 // make sure it's really a copy | 55 // make sure it's really a copy |
57 m2.To[0] = "fake@faker.example.com" | 56 m2.To[0] = "fake@faker.example.com" |
58 » » » So(m2.To, ShouldNotResembleV, m.To) | 57 » » » So(m2.To, ShouldNotResemble, m.To) |
59 | 58 |
60 m2.Headers["SomethingElse"] = []string{"noooo"} | 59 m2.Headers["SomethingElse"] = []string{"noooo"} |
61 » » » So(m2.Headers, ShouldNotResembleV, m.Headers) | 60 » » » So(m2.Headers, ShouldNotResemble, m.Headers) |
62 }) | 61 }) |
63 | 62 |
64 Convey("TestMessage is copyable", func() { | 63 Convey("TestMessage is copyable", func() { |
65 tm := &TestMessage{*m, []string{"application/msword"}} | 64 tm := &TestMessage{*m, []string{"application/msword"}} |
66 tm2 := tm.Copy() | 65 tm2 := tm.Copy() |
67 » » » So(tm, ShouldResembleV, tm2) | 66 » » » So(tm, ShouldResemble, tm2) |
68 | 67 |
69 tm2.MIMETypes[0] = "spam" | 68 tm2.MIMETypes[0] = "spam" |
70 » » » So(tm, ShouldNotResembleV, tm2) | 69 » » » So(tm, ShouldNotResemble, tm2) |
71 }) | 70 }) |
72 | 71 |
73 Convey("Message can be cast to an SDK Message", func() { | 72 Convey("Message can be cast to an SDK Message", func() { |
74 m2 := m.ToSDKMessage() | 73 m2 := m.ToSDKMessage() |
75 » » » So(m2.Sender, ShouldResembleV, m.Sender) | 74 » » » So(m2.Sender, ShouldResemble, m.Sender) |
76 » » » So(m2.ReplyTo, ShouldResembleV, m.ReplyTo) | 75 » » » So(m2.ReplyTo, ShouldResemble, m.ReplyTo) |
77 » » » So(m2.To, ShouldResembleV, m.To) | 76 » » » So(m2.To, ShouldResemble, m.To) |
78 » » » So(m2.Cc, ShouldResembleV, m.Cc) | 77 » » » So(m2.Cc, ShouldResemble, m.Cc) |
79 » » » So(m2.Bcc, ShouldResembleV, m.Bcc) | 78 » » » So(m2.Bcc, ShouldResemble, m.Bcc) |
80 » » » So(m2.Subject, ShouldResembleV, m.Subject) | 79 » » » So(m2.Subject, ShouldResemble, m.Subject) |
81 » » » So(m2.Body, ShouldResembleV, m.Body) | 80 » » » So(m2.Body, ShouldResemble, m.Body) |
82 » » » So(m2.HTMLBody, ShouldResembleV, m.HTMLBody) | 81 » » » So(m2.HTMLBody, ShouldResemble, m.HTMLBody) |
83 » » » So(m2.Headers, ShouldResembleV, m.Headers) | 82 » » » So(m2.Headers, ShouldResemble, m.Headers) |
84 | 83 |
85 » » » So((Attachment)(m2.Attachments[0]), ShouldResembleV, m.A
ttachments[0]) | 84 » » » So((Attachment)(m2.Attachments[0]), ShouldResemble, m.At
tachments[0]) |
86 }) | 85 }) |
87 }) | 86 }) |
88 } | 87 } |
OLD | NEW |