feat: init

This commit is contained in:
Rogee
2024-11-27 11:55:09 +08:00
parent e0eb7e5e2e
commit e4b9cc5f26
13 changed files with 462 additions and 2 deletions

34
pkg/wechat/wechat_test.go Normal file
View File

@@ -0,0 +1,34 @@
package wechat
import (
"testing"
log "github.com/sirupsen/logrus"
. "github.com/smartystreets/goconvey/convey"
)
const (
WechatAppID = "wxf5bf0adeb99c2afd"
WechatAppSecret = "3cf8fad4aa414f2b861399f111b22bb5"
WechatToken = "W8Xhw5TivYBgY"
WechatAesKey = "F6AqCxAV4W1eCrY6llJ2zapphKK49CQN3RgtPDrjhnI"
)
func TestWechatClient_GetAccessToken(t *testing.T) {
Convey("Test GetAccessToken", t, func() {
log.SetLevel(log.DebugLevel)
wechatClient := New(
WithAppID(WechatAppID),
WithAppSecret(WechatAppSecret),
WithAESKey(WechatAesKey),
WithToken(WechatToken),
WithClient(DefaultClient.DevMode()),
)
token, err := wechatClient.GetAccessToken()
So(err, ShouldBeNil)
So(token.AccessToken, ShouldNotBeEmpty)
So(token.ExpiresIn, ShouldBeGreaterThan, 0)
})
}