mirror of
https://github.com/nikoksr/notify.git
synced 2025-04-11 11:41:58 +02:00
refactor(service): make most amazon_sns types unexported
This commit is contained in:
parent
2e18096aea
commit
3c51987712
@ -10,22 +10,22 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// SNSSendMessageAPI Basic interface to send messages through SNS.
|
||||
// snsSendMessageAPI Basic interface to send messages through SNS.
|
||||
//
|
||||
//go:generate mockery --name=SNSSendMessageAPI --output=. --case=underscore --inpackage
|
||||
type SNSSendMessageAPI interface {
|
||||
//go:generate mockery --name=snsSendMessageAPI --output=. --case=underscore --inpackage
|
||||
type snsSendMessageAPI interface {
|
||||
SendMessage(ctx context.Context,
|
||||
params *sns.PublishInput,
|
||||
optFns ...func(*sns.Options)) (*sns.PublishOutput, error)
|
||||
}
|
||||
|
||||
// SNSSendMessageClient Client specific for SNS using aws sdk v2.
|
||||
type SNSSendMessageClient struct {
|
||||
// snsSendMessageClient Client specific for SNS using aws sdk v2.
|
||||
type snsSendMessageClient struct {
|
||||
client *sns.Client
|
||||
}
|
||||
|
||||
// SendMessage Client specific for SNS using aws sdk v2.
|
||||
func (s SNSSendMessageClient) SendMessage(ctx context.Context,
|
||||
func (s snsSendMessageClient) SendMessage(ctx context.Context,
|
||||
params *sns.PublishInput,
|
||||
optFns ...func(*sns.Options),
|
||||
) (*sns.PublishOutput, error) {
|
||||
@ -34,7 +34,7 @@ func (s SNSSendMessageClient) SendMessage(ctx context.Context,
|
||||
|
||||
// AmazonSNS Basic structure with SNS information
|
||||
type AmazonSNS struct {
|
||||
sendMessageClient SNSSendMessageAPI
|
||||
sendMessageClient snsSendMessageAPI
|
||||
queueTopics []string
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ func New(accessKeyID, secretKey, region string) (*AmazonSNS, error) {
|
||||
}
|
||||
client := sns.NewFromConfig(cfg)
|
||||
return &AmazonSNS{
|
||||
sendMessageClient: SNSSendMessageClient{client: client},
|
||||
sendMessageClient: snsSendMessageClient{client: client},
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ func TestAmazonSNS_AddReceivers(t *testing.T) {
|
||||
func TestAmazonSNS_SendMessageWithNoTopicsConfigured(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
mockSns := new(MockSNSSendMessageAPI)
|
||||
mockSns := new(mockSnsSendMessageAPI)
|
||||
amazonSNS := AmazonSNS{
|
||||
sendMessageClient: mockSns,
|
||||
}
|
||||
@ -47,7 +47,7 @@ func TestAmazonSNS_SendMessageWithNoTopicsConfigured(t *testing.T) {
|
||||
func TestAmazonSNS_SendMessageWithSucessAndOneTopicConfigured(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
mockSns := new(MockSNSSendMessageAPI)
|
||||
mockSns := new(mockSnsSendMessageAPI)
|
||||
output := sns.PublishOutput{}
|
||||
mockSns.On("SendMessage", mock.Anything, mock.Anything, mock.Anything).
|
||||
Return(&output, nil)
|
||||
@ -66,7 +66,7 @@ func TestAmazonSNS_SendMessageWithSucessAndOneTopicConfigured(t *testing.T) {
|
||||
func TestAmazonSNS_SendMessageWithSucessAndTwoTopicsConfigured(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
mockSns := new(MockSNSSendMessageAPI)
|
||||
mockSns := new(mockSnsSendMessageAPI)
|
||||
output := sns.PublishOutput{}
|
||||
mockSns.On("SendMessage", mock.Anything, mock.Anything, mock.Anything).
|
||||
Return(&output, nil)
|
||||
@ -88,7 +88,7 @@ func TestAmazonSNS_SendMessageWithSucessAndTwoTopicsConfigured(t *testing.T) {
|
||||
func TestAmazonSNS_SendMessageWithErrorAndOneQueueConfiguredShouldReturnError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
mockSns := new(MockSNSSendMessageAPI)
|
||||
mockSns := new(mockSnsSendMessageAPI)
|
||||
output := sns.PublishOutput{}
|
||||
mockSns.On("SendMessage", mock.Anything, mock.Anything, mock.Anything).
|
||||
Return(&output, errors.New("Error on SNS"))
|
||||
@ -109,7 +109,7 @@ func TestAmazonSNS_SendMessageWithErrorAndOneQueueConfiguredShouldReturnError(t
|
||||
func TestAmazonSNS_SendMessageWithErrorAndTwoQueueConfiguredShouldReturnErrorOnFirst(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
mockSns := new(MockSNSSendMessageAPI)
|
||||
mockSns := new(mockSnsSendMessageAPI)
|
||||
output := sns.PublishOutput{}
|
||||
mockSns.On("SendMessage", mock.Anything, mock.Anything, mock.Anything).
|
||||
Return(&output, errors.New("Error on SNS"))
|
||||
|
@ -9,13 +9,13 @@ import (
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// MockSNSSendMessageAPI is an autogenerated mock type for the SNSSendMessageAPI type
|
||||
type MockSNSSendMessageAPI struct {
|
||||
// mockSnsSendMessageAPI is an autogenerated mock type for the snsSendMessageAPI type
|
||||
type mockSnsSendMessageAPI struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// SendMessage provides a mock function with given fields: ctx, params, optFns
|
||||
func (_m *MockSNSSendMessageAPI) SendMessage(ctx context.Context, params *sns.PublishInput, optFns ...func(*sns.Options)) (*sns.PublishOutput, error) {
|
||||
func (_m *mockSnsSendMessageAPI) SendMessage(ctx context.Context, params *sns.PublishInput, optFns ...func(*sns.Options)) (*sns.PublishOutput, error) {
|
||||
_va := make([]interface{}, len(optFns))
|
||||
for _i := range optFns {
|
||||
_va[_i] = optFns[_i]
|
||||
@ -44,14 +44,14 @@ func (_m *MockSNSSendMessageAPI) SendMessage(ctx context.Context, params *sns.Pu
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewMockSNSSendMessageAPI interface {
|
||||
type mockConstructorTestingTnewMockSnsSendMessageAPI interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewMockSNSSendMessageAPI creates a new instance of MockSNSSendMessageAPI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewMockSNSSendMessageAPI(t mockConstructorTestingTNewMockSNSSendMessageAPI) *MockSNSSendMessageAPI {
|
||||
mock := &MockSNSSendMessageAPI{}
|
||||
// newMockSnsSendMessageAPI creates a new instance of mockSnsSendMessageAPI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func newMockSnsSendMessageAPI(t mockConstructorTestingTnewMockSnsSendMessageAPI) *mockSnsSendMessageAPI {
|
||||
mock := &mockSnsSendMessageAPI{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
Loading…
x
Reference in New Issue
Block a user