mirror of
https://github.com/silenceper/wechat.git
synced 2026-11-16 05:12:03 +08:00
Add JSSDK context method functionality (#828)
* Add JSSDK context method functionality * 善JSSDK上下文方法,并添加测试文件 * feat: 完善JSSDK上下文方法,保证协程安全,并添加测试文件 * 修改 import 包分组处理 * feat: 修改测试文件中 fmt.Print -> t.Log * 删除空行
This commit is contained in:
1 parent
26d2093bd7
commit
b639d2235d
6 files changed
+237
-9
No files matched your search
@@ -0,0 +1,22 @@
|
||||
package credential
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/h2non/gock.v1"
|
||||
)
|
||||
|
||||
// TestGetTicketFromServerContext 测试 GetTicketFromServerContext 函数
|
||||
func TestGetTicketFromServerContext(t *testing.T) {
|
||||
defer gock.Off()
|
||||
gock.New(fmt.Sprintf(getTicketURL, "arg-ak")).Reply(200).JSON(&ResTicket{Ticket: "mock-ticket", ExpiresIn: 10})
|
||||
|
||||
ticket, err := GetTicketFromServerContext(context.Background(), "arg-ak")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, int64(0), ticket.ErrCode)
|
||||
assert.Equal(t, "mock-ticket", ticket.Ticket, "they should be equal")
|
||||
assert.Equal(t, int64(10), ticket.ExpiresIn, "they should be equal")
|
||||
}
|
||||
Reference in new issue
Block a user