feat: add callback function to mock
This commit is contained in:
parent
a946f769ac
commit
1371889d6d
|
@ -43,7 +43,7 @@ func TestNewConfig_MissingEnvFile(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMockSendEmail(t *testing.T) {
|
||||
service := NewMockMailService()
|
||||
service := NewMockMailService(func(params ...interface{}) {})
|
||||
|
||||
emailData := EmailMessage{
|
||||
To: "test@example.com",
|
||||
|
|
|
@ -6,7 +6,9 @@ import (
|
|||
"net/smtp"
|
||||
)
|
||||
|
||||
func NewMockMailService() *EmailService {
|
||||
type MockCallbackFn func(params ...interface{})
|
||||
|
||||
func NewMockMailService(callbackFn MockCallbackFn, params ...interface{}) *EmailService {
|
||||
return &EmailService{
|
||||
auth: smtp.PlainAuth("", "", "", ""),
|
||||
host: "",
|
||||
|
@ -17,6 +19,7 @@ func NewMockMailService() *EmailService {
|
|||
ServerName: "",
|
||||
},
|
||||
dial: func(hostPort string) (SMTPClientIface, error) {
|
||||
callbackFn(params)
|
||||
return &mockSMTP{}, nil
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue