66 lines
981 B
Go
Executable File
66 lines
981 B
Go
Executable File
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"backend/pkg/pg"
|
|
"backend/pkg/service/model"
|
|
"backend/providers/wechat"
|
|
|
|
"git.ipao.vip/rogeecn/atom"
|
|
"github.com/jinzhu/copier"
|
|
)
|
|
|
|
func Test_GenModel(t *testing.T) {
|
|
err := atom.Serve(model.Options()...)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func Test_GenModel2(t *testing.T) {
|
|
token := &wechat.AuthorizeAccessToken{
|
|
AccessToken: "123",
|
|
RefreshToken: "123",
|
|
ExpiresIn: 123,
|
|
Openid: "123",
|
|
Scope: "123",
|
|
}
|
|
|
|
var oauthInfo pg.UserOAuth
|
|
copier.Copy(&oauthInfo, token)
|
|
|
|
t.Logf("%+v", oauthInfo)
|
|
}
|
|
|
|
type Response struct {
|
|
ErrCode int `json:"errcode"`
|
|
}
|
|
|
|
func (r *Response) Error() error {
|
|
return nil
|
|
}
|
|
|
|
type Access struct {
|
|
Response
|
|
AccessToken string `json:"access_token"`
|
|
}
|
|
|
|
func Test_Data(t *testing.T) {
|
|
data := &Access{
|
|
Response: Response{
|
|
ErrCode: 0,
|
|
},
|
|
AccessToken: "123",
|
|
}
|
|
b, err := json.Marshal(data)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
data.Error()
|
|
|
|
t.Logf("%s", b)
|
|
}
|