1
0
mirror of https://github.com/nikoksr/notify.git synced 2024-11-28 08:39:13 +02:00

test: apply test conventions for wechat service

This commit is contained in:
Stefanos Valoumas 2022-09-12 15:03:28 +03:00
parent ecaa74abdc
commit 29809e50f8
3 changed files with 34 additions and 3 deletions

View File

@ -1,4 +1,4 @@
// Code generated by mockery 2.7.4. DO NOT EDIT.
// Code generated by mockery v2.14.0. DO NOT EDIT.
package wechat
@ -25,3 +25,18 @@ func (_m *mockWechatMessageManager) Send(msg *message.CustomerMessage) error {
return r0
}
type mockConstructorTestingTnewMockWechatMessageManager interface {
mock.TestingT
Cleanup(func())
}
// newMockWechatMessageManager creates a new instance of mockWechatMessageManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func newMockWechatMessageManager(t mockConstructorTestingTnewMockWechatMessageManager) *mockWechatMessageManager {
mock := &mockWechatMessageManager{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}

View File

@ -27,6 +27,8 @@ type Config struct {
}
// wechatMessageManager abstracts go-wechat's message.Manager for writing unit tests
//
//go:generate mockery --name=wechatMessageManager --output=. --case=underscore --inpackage
type wechatMessageManager interface {
Send(msg *message.CustomerMessage) error
}

View File

@ -5,11 +5,25 @@ import (
"testing"
"github.com/pkg/errors"
"github.com/silenceper/wechat/v2/cache"
"github.com/silenceper/wechat/v2/officialaccount/message"
"github.com/stretchr/testify/require"
)
func TestAddReceivers(t *testing.T) {
func TestWeChat_New(t *testing.T) {
t.Parallel()
assert := require.New(t)
cache := &cache.Memory{}
cfg := &Config{
Cache: cache,
}
service := New(cfg)
assert.NotNil(service)
}
func TestWeChat_AddReceivers(t *testing.T) {
t.Parallel()
assert := require.New(t)
@ -23,7 +37,7 @@ func TestAddReceivers(t *testing.T) {
assert.Equal(svc.userIDs, userIDs)
}
func TestSend(t *testing.T) {
func TestWeChat_Send(t *testing.T) {
t.Parallel()
assert := require.New(t)