1
0
mirror of https://github.com/nikoksr/notify.git synced 2025-03-29 21:46:58 +02:00

test: apply test conventions for plivo service

This commit is contained in:
Stefanos Valoumas 2022-09-12 14:49:36 +03:00
parent 8af0b6ab8f
commit 74d4576a63
4 changed files with 56 additions and 39 deletions

View File

@ -1,36 +0,0 @@
// Code generated by mockery v2.5.1. DO NOT EDIT.
package plivo
import (
plivo "github.com/plivo/plivo-go/v7"
mock "github.com/stretchr/testify/mock"
)
// mockPlivoMsgClient is an autogenerated mock type for the mockPlivoMsgClient type
type mockPlivoMsgClient struct {
mock.Mock
}
// Create provides a mock function with given fields: _a0
func (_m *mockPlivoMsgClient) Create(_a0 plivo.MessageCreateParams) (*plivo.MessageCreateResponseBody, error) {
ret := _m.Called(_a0)
var r0 *plivo.MessageCreateResponseBody
if rf, ok := ret.Get(0).(func(plivo.MessageCreateParams) *plivo.MessageCreateResponseBody); ok {
r0 = rf(_a0)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*plivo.MessageCreateResponseBody)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(plivo.MessageCreateParams) error); ok {
r1 = rf(_a0)
} else {
r1 = ret.Error(1)
}
return r0, r1
}

View File

@ -0,0 +1,51 @@
// Code generated by mockery v2.14.0. DO NOT EDIT.
package plivo
import (
v7 "github.com/plivo/plivo-go/v7"
mock "github.com/stretchr/testify/mock"
)
// mockPlivoMsgClient is an autogenerated mock type for the plivoMsgClient type
type mockPlivoMsgClient struct {
mock.Mock
}
// Create provides a mock function with given fields: _a0
func (_m *mockPlivoMsgClient) Create(_a0 v7.MessageCreateParams) (*v7.MessageCreateResponseBody, error) {
ret := _m.Called(_a0)
var r0 *v7.MessageCreateResponseBody
if rf, ok := ret.Get(0).(func(v7.MessageCreateParams) *v7.MessageCreateResponseBody); ok {
r0 = rf(_a0)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*v7.MessageCreateResponseBody)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(v7.MessageCreateParams) error); ok {
r1 = rf(_a0)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
type mockConstructorTestingTnewMockPlivoMsgClient interface {
mock.TestingT
Cleanup(func())
}
// newMockPlivoMsgClient creates a new instance of mockPlivoMsgClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func newMockPlivoMsgClient(t mockConstructorTestingTnewMockPlivoMsgClient) *mockPlivoMsgClient {
mock := &mockPlivoMsgClient{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}

View File

@ -28,6 +28,8 @@ type MessageOptions struct {
}
// plivoMsgClient abstracts Plivo SDK for writing unit tests
//
//go:generate mockery --name=plivoMsgClient --output=. --case=underscore --inpackage
type plivoMsgClient interface {
Create(plivo.MessageCreateParams) (*plivo.MessageCreateResponseBody, error)
}

View File

@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
)
func TestNew(t *testing.T) {
func TestPlivo_New(t *testing.T) {
t.Parallel()
assert := require.New(t)
@ -35,7 +35,7 @@ func TestNew(t *testing.T) {
assert.NotNil(svc)
}
func TestAddReceivers(t *testing.T) {
func TestPlivo_AddReceivers(t *testing.T) {
t.Parallel()
assert := require.New(t)
@ -50,7 +50,7 @@ func TestAddReceivers(t *testing.T) {
assert.Equal(svc.destinations, nums)
}
func TestSend(t *testing.T) {
func TestPlivo_Send(t *testing.T) {
t.Parallel()
assert := require.New(t)