104 lines
2.3 KiB
Go
104 lines
2.3 KiB
Go
package email
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gopkg.in/gomail.v2"
|
|
)
|
|
|
|
func TestSendSimple(t *testing.T) {
|
|
setupDefault()
|
|
err := Send("test@kumoly.io",
|
|
[]string{"test@kumoly.io"}, "TestSendSimple",
|
|
&Body{
|
|
Content: `Testing`,
|
|
Actions: []Action{
|
|
{Instructions: "click",
|
|
Button: Button{
|
|
Text: "click me", Link: "kumoly.io",
|
|
},
|
|
},
|
|
{Instructions: "long button",
|
|
Button: Button{
|
|
Text: `long long
|
|
longlonglonglonglonglonglonglonglonglong
|
|
longlonglonglonglonglonglonglonglonglong
|
|
longlonglonglonglonglonglonglonglonglong
|
|
text`,
|
|
Link: "kumoly.io",
|
|
Color: "#90CAF9",
|
|
TextColor: "#000000",
|
|
},
|
|
},
|
|
{Instructions: "None",
|
|
Button: Button{},
|
|
},
|
|
{Instructions: "click",
|
|
InviteCode: "12354",
|
|
},
|
|
},
|
|
},
|
|
)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|
|
|
|
func TestSend(t *testing.T) {
|
|
setupDefault()
|
|
err := Send("test@kumoly.io",
|
|
[]string{"test@kumoly.io"}, "TestSend",
|
|
&Body{
|
|
App: App{
|
|
Logo: "https://www.taishinlife.com.tw/assets/images/ui/site-header/taishin/logo.svg",
|
|
Theme: "#d70c18",
|
|
FooterColor: "#ffffff",
|
|
},
|
|
Greeting: "歡迎",
|
|
Intros: []string{"testing 1.", "loramipsum...."},
|
|
Outros: []string{"testing 2,", "blah blah blah..."},
|
|
Actions: []Action{{Button: Button{Text: "click"}}},
|
|
Content: `
|
|
# Testing
|
|
|
|
| A | B | C |
|
|
| :------:| :-----------: | :-----------: |
|
|
| test |||
|
|
|| is ||
|
|
||| up |`,
|
|
},
|
|
)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|
|
func TestMaintain(t *testing.T) {
|
|
setupDefault()
|
|
// dial = &gomail.Dialer{Host: "localhost", Port: 25, SSL: false}
|
|
dial = gomail.NewDialer("smtp.gmail.com", 587, "rd.trac@arec.com", "hlllzqcfsedrqeul")
|
|
|
|
err := Send("rd.trac@arec.com",
|
|
[]string{"evanchen333@gmail.com"}, "TestMaintain",
|
|
&Body{
|
|
Greeting: "您好",
|
|
Receiver: "管理員",
|
|
Sender: "App System",
|
|
Content: `
|
|
> _Hermes_ service will shutdown the **1st August 2017** for maintenance operations.
|
|
|
|
Services will be unavailable based on the following schedule:
|
|
| Services | Downtime |
|
|
| :------:| :-----------: |
|
|
| Service A | 2AM to 3AM |
|
|
| Service B | 4AM to 5AM |
|
|
| Service C | 5AM to 6AM |
|
|
|
|
Feel free to contact us for any question regarding this matter at [support@hermes-example.com](mailto:support@hermes-example.com) or in our [Gitter](https://gitter.im/)
|
|
`,
|
|
},
|
|
)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|