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:
parent
b50efdf40b
commit
4585e9fc94
@ -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...)
|
||||
}
|
||||
|
||||
|
@ -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).
|
||||
|
@ -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"})
|
||||
|
@ -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()
|
||||
|
@ -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{
|
||||
|
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user