add testing

master
Evan Chen 2021-12-17 13:13:31 +08:00
parent 06889facfb
commit 3df6dfdc3f
3 changed files with 29 additions and 25 deletions

View File

@ -1,9 +1,6 @@
package main
import (
"time"
"github.com/rs/zerolog/log"
"kumoly.io/kumoly/app/auth"
"kumoly.io/kumoly/app/email"
"kumoly.io/kumoly/app/history"
@ -27,26 +24,6 @@ func main() {
&email.Service{})
go sys.Start()
time.Sleep(time.Second)
err := email.Send("test@kumoly.io",
[]string{"evanchen333@gmail.com"}, "Test Mail",
&email.Body{
Greeting: "歡迎",
Signature: "Best Regards",
Content: `
# Testing
a|b|c
-|-|-
test||
|is|
| |up`,
},
)
if err != nil {
log.Error().Err(err).Msg("failed to send email")
}
<-sys.Done()
}

View File

@ -297,8 +297,6 @@
{{/* Main Body */}}
{{ if (ne .Content "") }}
{{ .Content | ToHTML }}
{{ else }}
<p>No Body</p>
{{ end }}
{{/* Outros */}}

29
email/email_test.go Normal file
View File

@ -0,0 +1,29 @@
package email
import (
"testing"
)
func TestSend(t *testing.T) {
(&Service{}).Init()
err := Send("test@kumoly.io",
[]string{"evanchen333@gmail.com"}, "Test Mail 2",
&Body{
Greeting: "歡迎",
Signature: "Best Regards",
Intros: []string{"testing 1.", "loramipsum...."},
Outros: []string{"testing 2,", "blah blah blah..."},
Content: `
# Testing
a|b|c
-|-|-
test||
-|is|
-|-|up`,
},
)
if err != nil {
t.Error(err)
}
}