feat: expose mock email service function
This commit is contained in:
@@ -6,36 +6,53 @@ import (
|
||||
"net/smtp"
|
||||
)
|
||||
|
||||
type MockWriter struct{}
|
||||
func NewMockMailService() *EmailService {
|
||||
return &EmailService{
|
||||
auth: smtp.PlainAuth("", "", "", ""),
|
||||
host: "",
|
||||
port: "",
|
||||
from: "",
|
||||
tlsconfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
ServerName: "",
|
||||
},
|
||||
dial: func(hostPort string) (SMTPClientIface, error) {
|
||||
return &mockSMTP{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
func (w *MockWriter) Close() error {
|
||||
}
|
||||
|
||||
type mockWriter struct{}
|
||||
|
||||
func (w *mockWriter) Close() error {
|
||||
return nil
|
||||
}
|
||||
func (w *MockWriter) Write(p []byte) (n int, err error) {
|
||||
func (w *mockWriter) Write(p []byte) (n int, err error) {
|
||||
return 10, nil
|
||||
}
|
||||
|
||||
// Mock SMTP Client
|
||||
type MockSMTP struct{}
|
||||
type mockSMTP struct{}
|
||||
|
||||
func (m *MockSMTP) StartTLS(*tls.Config) error {
|
||||
func (m *mockSMTP) StartTLS(*tls.Config) error {
|
||||
return nil
|
||||
}
|
||||
func (m *MockSMTP) Auth(a smtp.Auth) error {
|
||||
func (m *mockSMTP) Auth(a smtp.Auth) error {
|
||||
return nil
|
||||
}
|
||||
func (m *MockSMTP) Close() error {
|
||||
func (m *mockSMTP) Close() error {
|
||||
return nil
|
||||
}
|
||||
func (m *MockSMTP) Data() (io.WriteCloser, error) {
|
||||
return &MockWriter{}, nil
|
||||
func (m *mockSMTP) Data() (io.WriteCloser, error) {
|
||||
return &mockWriter{}, nil
|
||||
}
|
||||
func (m *MockSMTP) Mail(from string) error {
|
||||
func (m *mockSMTP) Mail(from string) error {
|
||||
return nil
|
||||
}
|
||||
func (m *MockSMTP) Quit() error {
|
||||
func (m *mockSMTP) Quit() error {
|
||||
return nil
|
||||
}
|
||||
func (m *MockSMTP) Rcpt(to string) error {
|
||||
func (m *mockSMTP) Rcpt(to string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user