1
0
mirror of https://github.com/nikoksr/notify.git synced 2024-11-24 08:22:18 +02:00

test(go): allow for parallel tests

This commit is contained in:
Niko Köser 2022-04-22 20:45:29 +02:00
parent b50efdf40b
commit 4585e9fc94
No known key found for this signature in database
GPG Key ID: F3F28C118DAA6375
6 changed files with 35 additions and 3 deletions

View File

@ -25,7 +25,8 @@ type SNSSendMessageClient struct {
// SendMessage Client specific for SNS using aws sdk v2.
func (s SNSSendMessageClient) SendMessage(ctx context.Context,
params *sns.PublishInput,
optFns ...func(*sns.Options)) (*sns.PublishOutput, error) {
optFns ...func(*sns.Options),
) (*sns.PublishOutput, error) {
return s.client.Publish(ctx, params, optFns...)
}

View File

@ -16,12 +16,15 @@ type SNSSendMessageMock struct {
func (m *SNSSendMessageMock) SendMessage(ctx context.Context,
params *sns.PublishInput,
optFns ...func(*sns.Options)) (*sns.PublishOutput, error) {
optFns ...func(*sns.Options),
) (*sns.PublishOutput, error) {
args := m.Called(ctx, params, optFns)
return args.Get(0).(*sns.PublishOutput), args.Error(1)
}
func TestAddReceivers(t *testing.T) {
t.Parallel()
amazonSNS, err := New("", "", "")
if err != nil {
t.Error(err)
@ -30,6 +33,8 @@ func TestAddReceivers(t *testing.T) {
}
func TestSendMessageWithNoTopicsConfigured(t *testing.T) {
t.Parallel()
mockSns := new(SNSSendMessageMock)
amazonSNS := AmazonSNS{
sendMessageClient: mockSns,
@ -41,6 +46,8 @@ func TestSendMessageWithNoTopicsConfigured(t *testing.T) {
}
func TestSendMessageWithSucessAndOneTopicCOnfigured(t *testing.T) {
t.Parallel()
mockSns := new(SNSSendMessageMock)
output := sns.PublishOutput{}
mockSns.On("SendMessage", mock.Anything, mock.Anything, mock.Anything).
@ -58,6 +65,8 @@ func TestSendMessageWithSucessAndOneTopicCOnfigured(t *testing.T) {
}
func TestSendMessageWithSucessAndTwoTopicCOnfigured(t *testing.T) {
t.Parallel()
mockSns := new(SNSSendMessageMock)
output := sns.PublishOutput{}
mockSns.On("SendMessage", mock.Anything, mock.Anything, mock.Anything).
@ -78,6 +87,8 @@ func TestSendMessageWithSucessAndTwoTopicCOnfigured(t *testing.T) {
}
func TestSendMessageWithErrorAndOneQueueConfiguredShouldReturnError(t *testing.T) {
t.Parallel()
mockSns := new(SNSSendMessageMock)
output := sns.PublishOutput{}
mockSns.On("SendMessage", mock.Anything, mock.Anything, mock.Anything).
@ -97,6 +108,8 @@ func TestSendMessageWithErrorAndOneQueueConfiguredShouldReturnError(t *testing.T
}
func TestSendMessageWithErrorAndTwoQueueConfiguredShouldReturnErrorOnFirst(t *testing.T) {
t.Parallel()
mockSns := new(SNSSendMessageMock)
output := sns.PublishOutput{}
mockSns.On("SendMessage", mock.Anything, mock.Anything, mock.Anything).

View File

@ -5,11 +5,13 @@ import (
"errors"
"testing"
plivo "github.com/plivo/plivo-go/v7"
"github.com/plivo/plivo-go/v7"
"github.com/stretchr/testify/require"
)
func TestNew(t *testing.T) {
t.Parallel()
assert := require.New(t)
// nil ClientOptions
@ -34,6 +36,8 @@ func TestNew(t *testing.T) {
}
func TestAddReceivers(t *testing.T) {
t.Parallel()
assert := require.New(t)
svc, err := New(&ClientOptions{}, &MessageOptions{Source: "12345"})
@ -47,6 +51,8 @@ func TestAddReceivers(t *testing.T) {
}
func TestSend(t *testing.T) {
t.Parallel()
assert := require.New(t)
svc, err := New(&ClientOptions{}, &MessageOptions{Source: "12345"})

View File

@ -10,6 +10,8 @@ import (
)
func TestNew(t *testing.T) {
t.Parallel()
assert := require.New(t)
// Test creating a local writer with invalid log priority.
@ -38,6 +40,8 @@ func TestNew(t *testing.T) {
}
func TestSend(t *testing.T) {
t.Parallel()
assert := require.New(t)
ctx := context.Background()

View File

@ -10,6 +10,8 @@ import (
)
func TestAddReceivers(t *testing.T) {
t.Parallel()
assert := require.New(t)
svc := &Service{
@ -22,6 +24,8 @@ func TestAddReceivers(t *testing.T) {
}
func TestSend(t *testing.T) {
t.Parallel()
assert := require.New(t)
svc := &Service{

View File

@ -10,6 +10,8 @@ import (
)
func TestAddReceivers(t *testing.T) {
t.Parallel()
assert := require.New(t)
svc := &Service{
@ -22,6 +24,8 @@ func TestAddReceivers(t *testing.T) {
}
func TestSend(t *testing.T) {
t.Parallel()
assert := require.New(t)
svc := &Service{