diff --git a/pkg/async/notifications/implementations/sandbox_processor_test.go b/pkg/async/notifications/implementations/sandbox_processor_test.go index 6def96e99..a875c9247 100644 --- a/pkg/async/notifications/implementations/sandbox_processor_test.go +++ b/pkg/async/notifications/implementations/sandbox_processor_test.go @@ -6,6 +6,7 @@ import ( "github.com/flyteorg/flyteadmin/pkg/async/notifications/mocks" "github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin" + "github.com/pkg/errors" "github.com/stretchr/testify/assert" ) @@ -13,6 +14,7 @@ var mockSandboxEmailer mocks.MockEmailer func TestSandboxProcessor_StartProcessing(t *testing.T) { msgChan := make(chan []byte, 1) + msgChan <- msg testSandboxProcessor := NewSandboxProcessor(msgChan, &mockSandboxEmailer) sendEmailValidationFunc := func(ctx context.Context, email admin.EmailMessage) error { @@ -22,6 +24,27 @@ func TestSandboxProcessor_StartProcessing(t *testing.T) { assert.Equal(t, testEmail.SenderEmail, email.SenderEmail) return nil } + mockSandboxEmailer.SetSendEmailFunc(sendEmailValidationFunc) assert.Nil(t, testSandboxProcessor.(*SandboxProcessor).run()) } + +func TestSandboxProcessor_StartProcessingEmailError(t *testing.T) { + msgChan := make(chan []byte, 1) + msgChan <- msg + testSandboxProcessor := NewSandboxProcessor(msgChan, &mockSandboxEmailer) + + emailError := errors.New("error sending email") + sendEmailValidationFunc := func(ctx context.Context, email admin.EmailMessage) error { + return emailError + } + + mockSandboxEmailer.SetSendEmailFunc(sendEmailValidationFunc) + assert.NotNil(t, testSandboxProcessor.(*SandboxProcessor).run()) +} + +func TestSandboxProcessor_StopProcessing(t *testing.T) { + msgChan := make(chan []byte, 1) + testSandboxProcessor := NewSandboxProcessor(msgChan, &mockSandboxEmailer) + assert.Nil(t, testSandboxProcessor.StopProcessing()) +}