35 lines
802 B
Go
35 lines
802 B
Go
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)
|
|
})
|
|
}
|