feat: set up project
This commit is contained in:
52
internal/services/mail/mail_test.go
Normal file
52
internal/services/mail/mail_test.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package mail
|
||||
|
||||
import (
|
||||
"net/smtp"
|
||||
"testing"
|
||||
|
||||
"gitea.urkob.com/urko/btc-pay-checker/kit"
|
||||
"gitea.urkob.com/urko/btc-pay-checker/kit/cfg"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
mailSrv *MailService
|
||||
config *cfg.Config
|
||||
)
|
||||
|
||||
func init() {
|
||||
config = cfg.NewConfig(kit.RootDir() + "/.test.env")
|
||||
mailSrv = NewMailService(
|
||||
MailServiceConfig{
|
||||
Auth: smtp.PlainAuth("", config.MailUser, config.MailPassword, config.MailHost),
|
||||
Host: config.MailHost,
|
||||
Port: config.MailPort,
|
||||
From: config.MailFrom,
|
||||
TemplatesDir: config.MailTemplatesDir,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func Test_mailService_SendOK(t *testing.T) {
|
||||
dto := SendOK{
|
||||
Price: 10.2,
|
||||
ExplorerUrl: "test",
|
||||
TxID: "test-hash",
|
||||
To: config.MailTo,
|
||||
}
|
||||
|
||||
err := mailSrv.SendClientConfirm(dto)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func Test_mailService_SendConfirm(t *testing.T) {
|
||||
dto := SendOK{
|
||||
ExplorerUrl: "test",
|
||||
TxID: "test-hash",
|
||||
BlockHash: "block-hash",
|
||||
To: config.MailTo,
|
||||
}
|
||||
|
||||
err := mailSrv.SendProviderConfirm(dto)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
Reference in New Issue
Block a user