diff --git a/flyteadmin/pkg/async/notifications/implementations/smtp_emailer_test.go b/flyteadmin/pkg/async/notifications/implementations/smtp_emailer_test.go index 8af08f84e0..558a5d6408 100644 --- a/flyteadmin/pkg/async/notifications/implementations/smtp_emailer_test.go +++ b/flyteadmin/pkg/async/notifications/implementations/smtp_emailer_test.go @@ -95,16 +95,16 @@ func TestCreateClient(t *testing.T) { MinVersion: tls.VersionTLS13, } - smtpClient := notification_mocks.NewSMTPClient(t) - smtpClient.EXPECT().Hello("localhost").Return(nil).Times(1) - smtpClient.EXPECT().Extension("STARTTLS").Return(true, "").Times(1) - smtpClient.EXPECT().StartTLS(&tls.Config{ + smtpClient := ¬ification_mocks.SMTPClient{} + smtpClient.On("Hello", "localhost").Return(nil) + smtpClient.On("Extension", "STARTTLS").Return(true, "") + smtpClient.On("StartTLS", &tls.Config{ InsecureSkipVerify: false, ServerName: "localhost", MinVersion: tls.VersionTLS13, - }).Return(nil).Times(1) - smtpClient.EXPECT().Extension("AUTH").Return(true, "").Times(1) - smtpClient.EXPECT().Auth(auth).Return(nil).Times(1) + }).Return(nil) + smtpClient.On("Extension", "AUTH").Return(true, "") + smtpClient.On("Auth", auth).Return(nil) smtpEmailer := createSMTPEmailer(smtpClient, &tlsConf, &auth, nil) @@ -124,7 +124,7 @@ func TestCreateClientErrorCreatingClient(t *testing.T) { MinVersion: tls.VersionTLS13, } - smtpClient := notification_mocks.NewSMTPClient(t) + smtpClient := ¬ification_mocks.SMTPClient{} smtpEmailer := createSMTPEmailer(smtpClient, &tlsConf, &auth, errors.New("error creating client")) @@ -144,8 +144,8 @@ func TestCreateClientErrorHello(t *testing.T) { MinVersion: tls.VersionTLS13, } - smtpClient := notification_mocks.NewSMTPClient(t) - smtpClient.EXPECT().Hello("localhost").Return(errors.New("Error with hello")).Times(1) + smtpClient := ¬ification_mocks.SMTPClient{} + smtpClient.On("Hello", "localhost").Return(errors.New("Error with hello")) smtpEmailer := createSMTPEmailer(smtpClient, &tlsConf, &auth, nil) @@ -165,10 +165,10 @@ func TestCreateClientErrorStartTLS(t *testing.T) { MinVersion: tls.VersionTLS13, } - smtpClient := notification_mocks.NewSMTPClient(t) - smtpClient.EXPECT().Hello("localhost").Return(nil).Times(1) - smtpClient.EXPECT().Extension("STARTTLS").Return(true, "").Times(1) - smtpClient.EXPECT().StartTLS(&tls.Config{ + smtpClient := ¬ification_mocks.SMTPClient{} + smtpClient.On("Hello", "localhost").Return(nil).Times(1) + smtpClient.On("Extension", "STARTTLS").Return(true, "").Times(1) + smtpClient.On("StartTLS", &tls.Config{ InsecureSkipVerify: false, ServerName: "localhost", MinVersion: tls.VersionTLS13, @@ -192,16 +192,16 @@ func TestCreateClientErrorAuth(t *testing.T) { MinVersion: tls.VersionTLS13, } - smtpClient := notification_mocks.NewSMTPClient(t) - smtpClient.EXPECT().Hello("localhost").Return(nil).Times(1) - smtpClient.EXPECT().Extension("STARTTLS").Return(true, "").Times(1) - smtpClient.EXPECT().StartTLS(&tls.Config{ + smtpClient := ¬ification_mocks.SMTPClient{} + smtpClient.On("Hello", "localhost").Return(nil).Times(1) + smtpClient.On("Extension", "STARTTLS").Return(true, "").Times(1) + smtpClient.On("StartTLS", &tls.Config{ InsecureSkipVerify: false, ServerName: "localhost", MinVersion: tls.VersionTLS13, }).Return(nil).Times(1) - smtpClient.EXPECT().Extension("AUTH").Return(true, "").Times(1) - smtpClient.EXPECT().Auth(auth).Return(errors.New("Error with hello")).Times(1) + smtpClient.On("Extension", "AUTH").Return(true, "").Times(1) + smtpClient.On("Auth", auth).Return(errors.New("Error with hello")).Times(1) smtpEmailer := createSMTPEmailer(smtpClient, &tlsConf, &auth, nil) @@ -223,22 +223,22 @@ func TestSendMail(t *testing.T) { stringWriter := StringWriter{buffer: ""} - smtpClient := notification_mocks.NewSMTPClient(t) - smtpClient.EXPECT().Noop().Return(errors.New("no connection")).Times(1) - smtpClient.EXPECT().Close().Return(nil).Times(1) - smtpClient.EXPECT().Hello("localhost").Return(nil).Times(1) - smtpClient.EXPECT().Extension("STARTTLS").Return(true, "").Times(1) - smtpClient.EXPECT().StartTLS(&tls.Config{ + smtpClient := ¬ification_mocks.SMTPClient{} + smtpClient.On("Noop").Return(errors.New("no connection")).Times(1) + smtpClient.On("Close").Return(nil).Times(1) + smtpClient.On("Hello", "localhost").Return(nil).Times(1) + smtpClient.On("Extension", "STARTTLS").Return(true, "").Times(1) + smtpClient.On("StartTLS", &tls.Config{ InsecureSkipVerify: false, ServerName: "localhost", MinVersion: tls.VersionTLS13, }).Return(nil).Times(1) - smtpClient.EXPECT().Extension("AUTH").Return(true, "").Times(1) - smtpClient.EXPECT().Auth(auth).Return(nil).Times(1) - smtpClient.EXPECT().Mail("flyte@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Rcpt("alice@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Rcpt("bob@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Data().Return(&stringWriter, nil).Times(1) + smtpClient.On("Extension", "AUTH").Return(true, "").Times(1) + smtpClient.On("Auth", auth).Return(nil).Times(1) + smtpClient.On("Mail", "flyte@flyte.org").Return(nil).Times(1) + smtpClient.On("Rcpt", "alice@flyte.org").Return(nil).Times(1) + smtpClient.On("Rcpt", "bob@flyte.org").Return(nil).Times(1) + smtpClient.On("Data").Return(&stringWriter, nil).Times(1) smtpEmailer := createSMTPEmailer(smtpClient, &tlsConf, &auth, nil) @@ -266,10 +266,10 @@ func TestSendMailCreateClientError(t *testing.T) { MinVersion: tls.VersionTLS13, } - smtpClient := notification_mocks.NewSMTPClient(t) - smtpClient.EXPECT().Noop().Return(errors.New("no connection")).Times(1) - smtpClient.EXPECT().Close().Return(nil).Times(1) - smtpClient.EXPECT().Hello("localhost").Return(errors.New("error hello")).Times(1) + smtpClient := ¬ification_mocks.SMTPClient{} + smtpClient.On("Noop").Return(errors.New("no connection")).Times(1) + smtpClient.On("Close").Return(nil).Times(1) + smtpClient.On("Hello", "localhost").Return(errors.New("error hello")).Times(1) smtpEmailer := createSMTPEmailer(smtpClient, &tlsConf, &auth, nil) @@ -292,19 +292,19 @@ func TestSendMailErrorMail(t *testing.T) { MinVersion: tls.VersionTLS13, } - smtpClient := notification_mocks.NewSMTPClient(t) - smtpClient.EXPECT().Noop().Return(errors.New("no connection")).Times(1) - smtpClient.EXPECT().Close().Return(nil).Times(1) - smtpClient.EXPECT().Hello("localhost").Return(nil).Times(1) - smtpClient.EXPECT().Extension("STARTTLS").Return(true, "").Times(1) - smtpClient.EXPECT().StartTLS(&tls.Config{ + smtpClient := ¬ification_mocks.SMTPClient{} + smtpClient.On("Noop").Return(errors.New("no connection")).Times(1) + smtpClient.On("Close").Return(nil).Times(1) + smtpClient.On("Hello", "localhost").Return(nil).Times(1) + smtpClient.On("Extension", "STARTTLS").Return(true, "").Times(1) + smtpClient.On("StartTLS", &tls.Config{ InsecureSkipVerify: false, ServerName: "localhost", MinVersion: tls.VersionTLS13, }).Return(nil).Times(1) - smtpClient.EXPECT().Extension("AUTH").Return(true, "").Times(1) - smtpClient.EXPECT().Auth(auth).Return(nil).Times(1) - smtpClient.EXPECT().Mail("flyte@flyte.org").Return(errors.New("error sending mail")).Times(1) + smtpClient.On("Extension", "AUTH").Return(true, "").Times(1) + smtpClient.On("Auth", auth).Return(nil).Times(1) + smtpClient.On("Mail", "flyte@flyte.org").Return(errors.New("error sending mail")).Times(1) smtpEmailer := createSMTPEmailer(smtpClient, &tlsConf, &auth, nil) @@ -327,20 +327,20 @@ func TestSendMailErrorRecipient(t *testing.T) { MinVersion: tls.VersionTLS13, } - smtpClient := notification_mocks.NewSMTPClient(t) - smtpClient.EXPECT().Noop().Return(errors.New("no connection")).Times(1) - smtpClient.EXPECT().Close().Return(nil).Times(1) - smtpClient.EXPECT().Hello("localhost").Return(nil).Times(1) - smtpClient.EXPECT().Extension("STARTTLS").Return(true, "").Times(1) - smtpClient.EXPECT().StartTLS(&tls.Config{ + smtpClient := ¬ification_mocks.SMTPClient{} + smtpClient.On("Noop").Return(errors.New("no connection")).Times(1) + smtpClient.On("Close").Return(nil).Times(1) + smtpClient.On("Hello", "localhost").Return(nil).Times(1) + smtpClient.On("Extension", "STARTTLS").Return(true, "").Times(1) + smtpClient.On("StartTLS", &tls.Config{ InsecureSkipVerify: false, ServerName: "localhost", MinVersion: tls.VersionTLS13, }).Return(nil).Times(1) - smtpClient.EXPECT().Extension("AUTH").Return(true, "").Times(1) - smtpClient.EXPECT().Auth(auth).Return(nil).Times(1) - smtpClient.EXPECT().Mail("flyte@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Rcpt("alice@flyte.org").Return(errors.New("error adding recipient")).Times(1) + smtpClient.On("Extension", "AUTH").Return(true, "").Times(1) + smtpClient.On("Auth", auth).Return(nil).Times(1) + smtpClient.On("Mail", "flyte@flyte.org").Return(nil).Times(1) + smtpClient.On("Rcpt", "alice@flyte.org").Return(errors.New("error adding recipient")).Times(1) smtpEmailer := createSMTPEmailer(smtpClient, &tlsConf, &auth, nil) @@ -363,22 +363,22 @@ func TestSendMailErrorData(t *testing.T) { MinVersion: tls.VersionTLS13, } - smtpClient := notification_mocks.NewSMTPClient(t) - smtpClient.EXPECT().Noop().Return(errors.New("no connection")).Times(1) - smtpClient.EXPECT().Close().Return(nil).Times(1) - smtpClient.EXPECT().Hello("localhost").Return(nil).Times(1) - smtpClient.EXPECT().Extension("STARTTLS").Return(true, "").Times(1) - smtpClient.EXPECT().StartTLS(&tls.Config{ + smtpClient := ¬ification_mocks.SMTPClient{} + smtpClient.On("Noop").Return(errors.New("no connection")).Times(1) + smtpClient.On("Close").Return(nil).Times(1) + smtpClient.On("Hello", "localhost").Return(nil).Times(1) + smtpClient.On("Extension", "STARTTLS").Return(true, "").Times(1) + smtpClient.On("StartTLS", &tls.Config{ InsecureSkipVerify: false, ServerName: "localhost", MinVersion: tls.VersionTLS13, }).Return(nil).Times(1) - smtpClient.EXPECT().Extension("AUTH").Return(true, "").Times(1) - smtpClient.EXPECT().Auth(auth).Return(nil).Times(1) - smtpClient.EXPECT().Mail("flyte@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Rcpt("alice@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Rcpt("bob@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Data().Return(nil, errors.New("error creating data writer")).Times(1) + smtpClient.On("Extension", "AUTH").Return(true, "").Times(1) + smtpClient.On("Auth", auth).Return(nil).Times(1) + smtpClient.On("Mail", "flyte@flyte.org").Return(nil).Times(1) + smtpClient.On("Rcpt", "alice@flyte.org").Return(nil).Times(1) + smtpClient.On("Rcpt", "bob@flyte.org").Return(nil).Times(1) + smtpClient.On("Data").Return(nil, errors.New("error creating data writer")).Times(1) smtpEmailer := createSMTPEmailer(smtpClient, &tlsConf, &auth, nil) @@ -404,22 +404,22 @@ func TestSendMailErrorWriting(t *testing.T) { stringWriter := StringWriter{buffer: "", writeErr: errors.New("error writing"), closeErr: nil} - smtpClient := notification_mocks.NewSMTPClient(t) - smtpClient.EXPECT().Noop().Return(errors.New("no connection")).Times(1) - smtpClient.EXPECT().Close().Return(nil).Times(1) - smtpClient.EXPECT().Hello("localhost").Return(nil).Times(1) - smtpClient.EXPECT().Extension("STARTTLS").Return(true, "").Times(1) - smtpClient.EXPECT().StartTLS(&tls.Config{ + smtpClient := ¬ification_mocks.SMTPClient{} + smtpClient.On("Noop").Return(errors.New("no connection")).Times(1) + smtpClient.On("Close").Return(nil).Times(1) + smtpClient.On("Hello", "localhost").Return(nil).Times(1) + smtpClient.On("Extension", "STARTTLS").Return(true, "").Times(1) + smtpClient.On("StartTLS", &tls.Config{ InsecureSkipVerify: false, ServerName: "localhost", MinVersion: tls.VersionTLS13, }).Return(nil).Times(1) - smtpClient.EXPECT().Extension("AUTH").Return(true, "").Times(1) - smtpClient.EXPECT().Auth(auth).Return(nil).Times(1) - smtpClient.EXPECT().Mail("flyte@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Rcpt("alice@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Rcpt("bob@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Data().Return(&stringWriter, nil).Times(1) + smtpClient.On("Extension", "AUTH").Return(true, "").Times(1) + smtpClient.On("Auth", auth).Return(nil).Times(1) + smtpClient.On("Mail", "flyte@flyte.org").Return(nil).Times(1) + smtpClient.On("Rcpt", "alice@flyte.org").Return(nil).Times(1) + smtpClient.On("Rcpt", "bob@flyte.org").Return(nil).Times(1) + smtpClient.On("Data").Return(&stringWriter, nil).Times(1) smtpEmailer := createSMTPEmailer(smtpClient, &tlsConf, &auth, nil) @@ -445,22 +445,22 @@ func TestSendMailErrorClose(t *testing.T) { stringWriter := StringWriter{buffer: "", writeErr: nil, closeErr: errors.New("error writing")} - smtpClient := notification_mocks.NewSMTPClient(t) - smtpClient.EXPECT().Noop().Return(errors.New("no connection")).Times(1) - smtpClient.EXPECT().Close().Return(nil).Times(1) - smtpClient.EXPECT().Hello("localhost").Return(nil).Times(1) - smtpClient.EXPECT().Extension("STARTTLS").Return(true, "").Times(1) - smtpClient.EXPECT().StartTLS(&tls.Config{ + smtpClient := ¬ification_mocks.SMTPClient{} + smtpClient.On("Noop").Return(errors.New("no connection")).Times(1) + smtpClient.On("Close").Return(nil).Times(1) + smtpClient.On("Hello", "localhost").Return(nil).Times(1) + smtpClient.On("Extension", "STARTTLS").Return(true, "").Times(1) + smtpClient.On("StartTLS", &tls.Config{ InsecureSkipVerify: false, ServerName: "localhost", MinVersion: tls.VersionTLS13, }).Return(nil).Times(1) - smtpClient.EXPECT().Extension("AUTH").Return(true, "").Times(1) - smtpClient.EXPECT().Auth(auth).Return(nil).Times(1) - smtpClient.EXPECT().Mail("flyte@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Rcpt("alice@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Rcpt("bob@flyte.org").Return(nil).Times(1) - smtpClient.EXPECT().Data().Return(&stringWriter, nil).Times(1) + smtpClient.On("Extension", "AUTH").Return(true, "").Times(1) + smtpClient.On("Auth", auth).Return(nil).Times(1) + smtpClient.On("Mail", "flyte@flyte.org").Return(nil).Times(1) + smtpClient.On("Rcpt", "alice@flyte.org").Return(nil).Times(1) + smtpClient.On("Rcpt", "bob@flyte.org").Return(nil).Times(1) + smtpClient.On("Data").Return(&stringWriter, nil).Times(1) smtpEmailer := createSMTPEmailer(smtpClient, &tlsConf, &auth, nil) diff --git a/flyteadmin/pkg/async/notifications/mocks/smtp_client.go b/flyteadmin/pkg/async/notifications/mocks/smtp_client.go index 39c3a63caa..11dafefc9c 100644 --- a/flyteadmin/pkg/async/notifications/mocks/smtp_client.go +++ b/flyteadmin/pkg/async/notifications/mocks/smtp_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.1. DO NOT EDIT. +// Code generated by mockery v1.0.1. DO NOT EDIT. package mocks @@ -16,22 +16,28 @@ type SMTPClient struct { mock.Mock } -type SMTPClient_Expecter struct { - mock *mock.Mock +type SMTPClient_Auth struct { + *mock.Call +} + +func (_m SMTPClient_Auth) Return(_a0 error) *SMTPClient_Auth { + return &SMTPClient_Auth{Call: _m.Call.Return(_a0)} +} + +func (_m *SMTPClient) OnAuth(a smtp.Auth) *SMTPClient_Auth { + c_call := _m.On("Auth", a) + return &SMTPClient_Auth{Call: c_call} } -func (_m *SMTPClient) EXPECT() *SMTPClient_Expecter { - return &SMTPClient_Expecter{mock: &_m.Mock} +func (_m *SMTPClient) OnAuthMatch(matchers ...interface{}) *SMTPClient_Auth { + c_call := _m.On("Auth", matchers...) + return &SMTPClient_Auth{Call: c_call} } // Auth provides a mock function with given fields: a func (_m *SMTPClient) Auth(a smtp.Auth) error { ret := _m.Called(a) - if len(ret) == 0 { - panic("no return value specified for Auth") - } - var r0 error if rf, ok := ret.Get(0).(func(smtp.Auth) error); ok { r0 = rf(a) @@ -42,42 +48,28 @@ func (_m *SMTPClient) Auth(a smtp.Auth) error { return r0 } -// SMTPClient_Auth_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Auth' -type SMTPClient_Auth_Call struct { +type SMTPClient_Close struct { *mock.Call } -// Auth is a helper method to define mock.On call -// - a smtp.Auth -func (_e *SMTPClient_Expecter) Auth(a interface{}) *SMTPClient_Auth_Call { - return &SMTPClient_Auth_Call{Call: _e.mock.On("Auth", a)} +func (_m SMTPClient_Close) Return(_a0 error) *SMTPClient_Close { + return &SMTPClient_Close{Call: _m.Call.Return(_a0)} } -func (_c *SMTPClient_Auth_Call) Run(run func(a smtp.Auth)) *SMTPClient_Auth_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(smtp.Auth)) - }) - return _c +func (_m *SMTPClient) OnClose() *SMTPClient_Close { + c_call := _m.On("Close") + return &SMTPClient_Close{Call: c_call} } -func (_c *SMTPClient_Auth_Call) Return(_a0 error) *SMTPClient_Auth_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *SMTPClient_Auth_Call) RunAndReturn(run func(smtp.Auth) error) *SMTPClient_Auth_Call { - _c.Call.Return(run) - return _c +func (_m *SMTPClient) OnCloseMatch(matchers ...interface{}) *SMTPClient_Close { + c_call := _m.On("Close", matchers...) + return &SMTPClient_Close{Call: c_call} } // Close provides a mock function with given fields: func (_m *SMTPClient) Close() error { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Close") - } - var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -88,46 +80,29 @@ func (_m *SMTPClient) Close() error { return r0 } -// SMTPClient_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close' -type SMTPClient_Close_Call struct { +type SMTPClient_Data struct { *mock.Call } -// Close is a helper method to define mock.On call -func (_e *SMTPClient_Expecter) Close() *SMTPClient_Close_Call { - return &SMTPClient_Close_Call{Call: _e.mock.On("Close")} +func (_m SMTPClient_Data) Return(_a0 io.WriteCloser, _a1 error) *SMTPClient_Data { + return &SMTPClient_Data{Call: _m.Call.Return(_a0, _a1)} } -func (_c *SMTPClient_Close_Call) Run(run func()) *SMTPClient_Close_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c +func (_m *SMTPClient) OnData() *SMTPClient_Data { + c_call := _m.On("Data") + return &SMTPClient_Data{Call: c_call} } -func (_c *SMTPClient_Close_Call) Return(_a0 error) *SMTPClient_Close_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *SMTPClient_Close_Call) RunAndReturn(run func() error) *SMTPClient_Close_Call { - _c.Call.Return(run) - return _c +func (_m *SMTPClient) OnDataMatch(matchers ...interface{}) *SMTPClient_Data { + c_call := _m.On("Data", matchers...) + return &SMTPClient_Data{Call: c_call} } // Data provides a mock function with given fields: func (_m *SMTPClient) Data() (io.WriteCloser, error) { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Data") - } - var r0 io.WriteCloser - var r1 error - if rf, ok := ret.Get(0).(func() (io.WriteCloser, error)); ok { - return rf() - } if rf, ok := ret.Get(0).(func() io.WriteCloser); ok { r0 = rf() } else { @@ -136,6 +111,7 @@ func (_m *SMTPClient) Data() (io.WriteCloser, error) { } } + var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -145,52 +121,36 @@ func (_m *SMTPClient) Data() (io.WriteCloser, error) { return r0, r1 } -// SMTPClient_Data_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Data' -type SMTPClient_Data_Call struct { +type SMTPClient_Extension struct { *mock.Call } -// Data is a helper method to define mock.On call -func (_e *SMTPClient_Expecter) Data() *SMTPClient_Data_Call { - return &SMTPClient_Data_Call{Call: _e.mock.On("Data")} -} - -func (_c *SMTPClient_Data_Call) Run(run func()) *SMTPClient_Data_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c +func (_m SMTPClient_Extension) Return(_a0 bool, _a1 string) *SMTPClient_Extension { + return &SMTPClient_Extension{Call: _m.Call.Return(_a0, _a1)} } -func (_c *SMTPClient_Data_Call) Return(_a0 io.WriteCloser, _a1 error) *SMTPClient_Data_Call { - _c.Call.Return(_a0, _a1) - return _c +func (_m *SMTPClient) OnExtension(ext string) *SMTPClient_Extension { + c_call := _m.On("Extension", ext) + return &SMTPClient_Extension{Call: c_call} } -func (_c *SMTPClient_Data_Call) RunAndReturn(run func() (io.WriteCloser, error)) *SMTPClient_Data_Call { - _c.Call.Return(run) - return _c +func (_m *SMTPClient) OnExtensionMatch(matchers ...interface{}) *SMTPClient_Extension { + c_call := _m.On("Extension", matchers...) + return &SMTPClient_Extension{Call: c_call} } // Extension provides a mock function with given fields: ext func (_m *SMTPClient) Extension(ext string) (bool, string) { ret := _m.Called(ext) - if len(ret) == 0 { - panic("no return value specified for Extension") - } - var r0 bool - var r1 string - if rf, ok := ret.Get(0).(func(string) (bool, string)); ok { - return rf(ext) - } if rf, ok := ret.Get(0).(func(string) bool); ok { r0 = rf(ext) } else { r0 = ret.Get(0).(bool) } + var r1 string if rf, ok := ret.Get(1).(func(string) string); ok { r1 = rf(ext) } else { @@ -200,42 +160,28 @@ func (_m *SMTPClient) Extension(ext string) (bool, string) { return r0, r1 } -// SMTPClient_Extension_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Extension' -type SMTPClient_Extension_Call struct { +type SMTPClient_Hello struct { *mock.Call } -// Extension is a helper method to define mock.On call -// - ext string -func (_e *SMTPClient_Expecter) Extension(ext interface{}) *SMTPClient_Extension_Call { - return &SMTPClient_Extension_Call{Call: _e.mock.On("Extension", ext)} -} - -func (_c *SMTPClient_Extension_Call) Run(run func(ext string)) *SMTPClient_Extension_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c +func (_m SMTPClient_Hello) Return(_a0 error) *SMTPClient_Hello { + return &SMTPClient_Hello{Call: _m.Call.Return(_a0)} } -func (_c *SMTPClient_Extension_Call) Return(_a0 bool, _a1 string) *SMTPClient_Extension_Call { - _c.Call.Return(_a0, _a1) - return _c +func (_m *SMTPClient) OnHello(localName string) *SMTPClient_Hello { + c_call := _m.On("Hello", localName) + return &SMTPClient_Hello{Call: c_call} } -func (_c *SMTPClient_Extension_Call) RunAndReturn(run func(string) (bool, string)) *SMTPClient_Extension_Call { - _c.Call.Return(run) - return _c +func (_m *SMTPClient) OnHelloMatch(matchers ...interface{}) *SMTPClient_Hello { + c_call := _m.On("Hello", matchers...) + return &SMTPClient_Hello{Call: c_call} } // Hello provides a mock function with given fields: localName func (_m *SMTPClient) Hello(localName string) error { ret := _m.Called(localName) - if len(ret) == 0 { - panic("no return value specified for Hello") - } - var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(localName) @@ -246,42 +192,28 @@ func (_m *SMTPClient) Hello(localName string) error { return r0 } -// SMTPClient_Hello_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Hello' -type SMTPClient_Hello_Call struct { +type SMTPClient_Mail struct { *mock.Call } -// Hello is a helper method to define mock.On call -// - localName string -func (_e *SMTPClient_Expecter) Hello(localName interface{}) *SMTPClient_Hello_Call { - return &SMTPClient_Hello_Call{Call: _e.mock.On("Hello", localName)} -} - -func (_c *SMTPClient_Hello_Call) Run(run func(localName string)) *SMTPClient_Hello_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c +func (_m SMTPClient_Mail) Return(_a0 error) *SMTPClient_Mail { + return &SMTPClient_Mail{Call: _m.Call.Return(_a0)} } -func (_c *SMTPClient_Hello_Call) Return(_a0 error) *SMTPClient_Hello_Call { - _c.Call.Return(_a0) - return _c +func (_m *SMTPClient) OnMail(from string) *SMTPClient_Mail { + c_call := _m.On("Mail", from) + return &SMTPClient_Mail{Call: c_call} } -func (_c *SMTPClient_Hello_Call) RunAndReturn(run func(string) error) *SMTPClient_Hello_Call { - _c.Call.Return(run) - return _c +func (_m *SMTPClient) OnMailMatch(matchers ...interface{}) *SMTPClient_Mail { + c_call := _m.On("Mail", matchers...) + return &SMTPClient_Mail{Call: c_call} } // Mail provides a mock function with given fields: from func (_m *SMTPClient) Mail(from string) error { ret := _m.Called(from) - if len(ret) == 0 { - panic("no return value specified for Mail") - } - var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(from) @@ -292,42 +224,28 @@ func (_m *SMTPClient) Mail(from string) error { return r0 } -// SMTPClient_Mail_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Mail' -type SMTPClient_Mail_Call struct { +type SMTPClient_Noop struct { *mock.Call } -// Mail is a helper method to define mock.On call -// - from string -func (_e *SMTPClient_Expecter) Mail(from interface{}) *SMTPClient_Mail_Call { - return &SMTPClient_Mail_Call{Call: _e.mock.On("Mail", from)} -} - -func (_c *SMTPClient_Mail_Call) Run(run func(from string)) *SMTPClient_Mail_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c +func (_m SMTPClient_Noop) Return(_a0 error) *SMTPClient_Noop { + return &SMTPClient_Noop{Call: _m.Call.Return(_a0)} } -func (_c *SMTPClient_Mail_Call) Return(_a0 error) *SMTPClient_Mail_Call { - _c.Call.Return(_a0) - return _c +func (_m *SMTPClient) OnNoop() *SMTPClient_Noop { + c_call := _m.On("Noop") + return &SMTPClient_Noop{Call: c_call} } -func (_c *SMTPClient_Mail_Call) RunAndReturn(run func(string) error) *SMTPClient_Mail_Call { - _c.Call.Return(run) - return _c +func (_m *SMTPClient) OnNoopMatch(matchers ...interface{}) *SMTPClient_Noop { + c_call := _m.On("Noop", matchers...) + return &SMTPClient_Noop{Call: c_call} } // Noop provides a mock function with given fields: func (_m *SMTPClient) Noop() error { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Noop") - } - var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -338,41 +256,28 @@ func (_m *SMTPClient) Noop() error { return r0 } -// SMTPClient_Noop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Noop' -type SMTPClient_Noop_Call struct { +type SMTPClient_Rcpt struct { *mock.Call } -// Noop is a helper method to define mock.On call -func (_e *SMTPClient_Expecter) Noop() *SMTPClient_Noop_Call { - return &SMTPClient_Noop_Call{Call: _e.mock.On("Noop")} +func (_m SMTPClient_Rcpt) Return(_a0 error) *SMTPClient_Rcpt { + return &SMTPClient_Rcpt{Call: _m.Call.Return(_a0)} } -func (_c *SMTPClient_Noop_Call) Run(run func()) *SMTPClient_Noop_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c +func (_m *SMTPClient) OnRcpt(to string) *SMTPClient_Rcpt { + c_call := _m.On("Rcpt", to) + return &SMTPClient_Rcpt{Call: c_call} } -func (_c *SMTPClient_Noop_Call) Return(_a0 error) *SMTPClient_Noop_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *SMTPClient_Noop_Call) RunAndReturn(run func() error) *SMTPClient_Noop_Call { - _c.Call.Return(run) - return _c +func (_m *SMTPClient) OnRcptMatch(matchers ...interface{}) *SMTPClient_Rcpt { + c_call := _m.On("Rcpt", matchers...) + return &SMTPClient_Rcpt{Call: c_call} } // Rcpt provides a mock function with given fields: to func (_m *SMTPClient) Rcpt(to string) error { ret := _m.Called(to) - if len(ret) == 0 { - panic("no return value specified for Rcpt") - } - var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(to) @@ -383,42 +288,28 @@ func (_m *SMTPClient) Rcpt(to string) error { return r0 } -// SMTPClient_Rcpt_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Rcpt' -type SMTPClient_Rcpt_Call struct { +type SMTPClient_StartTLS struct { *mock.Call } -// Rcpt is a helper method to define mock.On call -// - to string -func (_e *SMTPClient_Expecter) Rcpt(to interface{}) *SMTPClient_Rcpt_Call { - return &SMTPClient_Rcpt_Call{Call: _e.mock.On("Rcpt", to)} +func (_m SMTPClient_StartTLS) Return(_a0 error) *SMTPClient_StartTLS { + return &SMTPClient_StartTLS{Call: _m.Call.Return(_a0)} } -func (_c *SMTPClient_Rcpt_Call) Run(run func(to string)) *SMTPClient_Rcpt_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c +func (_m *SMTPClient) OnStartTLS(config *tls.Config) *SMTPClient_StartTLS { + c_call := _m.On("StartTLS", config) + return &SMTPClient_StartTLS{Call: c_call} } -func (_c *SMTPClient_Rcpt_Call) Return(_a0 error) *SMTPClient_Rcpt_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *SMTPClient_Rcpt_Call) RunAndReturn(run func(string) error) *SMTPClient_Rcpt_Call { - _c.Call.Return(run) - return _c +func (_m *SMTPClient) OnStartTLSMatch(matchers ...interface{}) *SMTPClient_StartTLS { + c_call := _m.On("StartTLS", matchers...) + return &SMTPClient_StartTLS{Call: c_call} } // StartTLS provides a mock function with given fields: config func (_m *SMTPClient) StartTLS(config *tls.Config) error { ret := _m.Called(config) - if len(ret) == 0 { - panic("no return value specified for StartTLS") - } - var r0 error if rf, ok := ret.Get(0).(func(*tls.Config) error); ok { r0 = rf(config) @@ -428,45 +319,3 @@ func (_m *SMTPClient) StartTLS(config *tls.Config) error { return r0 } - -// SMTPClient_StartTLS_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartTLS' -type SMTPClient_StartTLS_Call struct { - *mock.Call -} - -// StartTLS is a helper method to define mock.On call -// - config *tls.Config -func (_e *SMTPClient_Expecter) StartTLS(config interface{}) *SMTPClient_StartTLS_Call { - return &SMTPClient_StartTLS_Call{Call: _e.mock.On("StartTLS", config)} -} - -func (_c *SMTPClient_StartTLS_Call) Run(run func(config *tls.Config)) *SMTPClient_StartTLS_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*tls.Config)) - }) - return _c -} - -func (_c *SMTPClient_StartTLS_Call) Return(_a0 error) *SMTPClient_StartTLS_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *SMTPClient_StartTLS_Call) RunAndReturn(run func(*tls.Config) error) *SMTPClient_StartTLS_Call { - _c.Call.Return(run) - return _c -} - -// NewSMTPClient creates a new instance of SMTPClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewSMTPClient(t interface { - mock.TestingT - Cleanup(func()) -}) *SMTPClient { - mock := &SMTPClient{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -}