Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(services): apply mock and naming conventions #391

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: apply test conventions for wechat service
  • Loading branch information
svaloumas committed Sep 12, 2022
commit 29809e50f8ef5687813df4168caa482f9034c7ab

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions service/wechat/wechat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 16 additions & 2 deletions service/wechat/wechat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down