mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 21:02:25 +08:00
19 lines
513 B
Go
19 lines
513 B
Go
package credential
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"gopkg.in/h2non/gock.v1"
|
|
)
|
|
|
|
func TestGetTicketFromServer(t *testing.T) {
|
|
defer gock.Off()
|
|
gock.New(getTicketURL).Reply(200).JSON(&ResTicket{Ticket: "mock-ticket", ExpiresIn: 10})
|
|
ticket, err := GetTicketFromServer("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")
|
|
}
|