Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library(
name = "go_default_library",
srcs = [
"acc.go",
"dao.go",
"hbase_login_log.go",
"hbase_pwd_log.go",
"mysql.go",
],
importpath = "go-common/app/job/main/passport/dao",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/job/main/passport/conf:go_default_library",
"//app/job/main/passport/model:go_default_library",
"//library/database/hbase.v2:go_default_library",
"//library/database/sql:go_default_library",
"//library/ecode:go_default_library",
"//library/log:go_default_library",
"//library/net/http/blademaster:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = [
"acc_test.go",
"dao_test.go",
"hbase_login_log_test.go",
"hbase_pwd_log_test.go",
"mysql_test.go",
],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = [
"//app/job/main/passport/conf:go_default_library",
"//app/job/main/passport/model:go_default_library",
"//library/database/hbase.v2:go_default_library",
"//library/database/sql:go_default_library",
"//library/ecode:go_default_library",
"//library/net/http/blademaster:go_default_library",
"//library/queue/databus:go_default_library",
"//library/time:go_default_library",
"//vendor/github.com/bouk/monkey:go_default_library",
"//vendor/github.com/smartystreets/goconvey/convey:go_default_library",
"//vendor/github.com/tsuna/gohbase/hrpc:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,76 @@
package dao
import (
"context"
"net/url"
"strconv"
"go-common/app/job/main/passport/model"
"go-common/library/ecode"
"go-common/library/log"
)
// SetToken set token via passport api.
func (d *Dao) SetToken(c context.Context, t *model.Token) (err error) {
params := url.Values{}
params.Set("mid", strconv.FormatInt(t.Mid, 10))
params.Set("appid", strconv.FormatInt(t.Appid, 10))
params.Set("appSubid", strconv.FormatInt(t.Subid, 10))
params.Set("accessToken", t.Token)
params.Set("refreshToken", t.RToken)
params.Set("tp", strconv.FormatInt(t.Type, 10))
params.Set("createAt", strconv.FormatInt(t.CTime, 10))
params.Set("expires", strconv.FormatInt(t.Expires, 10))
params.Set("from", "passport-job")
var res struct {
Code int `json:"code"`
}
if err = d.client.Post(context.TODO(), d.setTokenURI, "127.0.0.1", params, &res); err != nil {
log.Error("d.client.Get error(%v)", err)
return
}
if res.Code != 0 {
err = ecode.Int(res.Code)
log.Error("set token url(%s) err(%v)", d.setTokenURI+"?"+params.Encode(), err)
}
return
}
// DelCache del cache via passport api.
func (d *Dao) DelCache(c context.Context, accessKey string) (err error) {
params := url.Values{}
params.Set("access_key", accessKey)
var res struct {
Code int `json:"code"`
}
if err = d.client.Get(context.TODO(), d.delCacheURI, "", params, &res); err != nil {
log.Error("d.client.Get url(%s) error(%v)", d.delCacheURI+"?"+params.Encode(), err)
return
}
if res.Code != 0 {
err = ecode.Int(res.Code)
log.Error("del cache url(%s) error(%v)", d.delCacheURI+"?"+params.Encode(), err)
}
return
}
// NotifyGame notify game.
func (d *Dao) NotifyGame(token *model.AccessInfo, action string) (err error) {
params := url.Values{}
params.Set("modifiedAttr", action)
params.Set("mid", strconv.FormatInt(token.Mid, 10))
params.Set("access_token", token.Token)
params.Set("from", "passport-job")
var res struct {
Code int `json:"code"`
}
if err = d.gameClient.Get(context.TODO(), d.delGameCacheURI, "127.0.0.1", params, &res); err != nil {
log.Error("d.client.Get url(%s) error(%v)", d.delGameCacheURI+"?"+params.Encode(), err)
return
}
if res.Code != 0 {
err = ecode.Int(res.Code)
log.Error("url(%s) err(%v)", d.delGameCacheURI+"?"+params.Encode(), err)
}
return
}

View File

@@ -0,0 +1,65 @@
package dao
import (
"context"
"go-common/app/job/main/passport/model"
"go-common/library/ecode"
bm "go-common/library/net/http/blademaster"
"net/url"
"reflect"
"testing"
"github.com/bouk/monkey"
"github.com/smartystreets/goconvey/convey"
)
func TestDao_SetToken(t *testing.T) {
convey.Convey("SetToken", t, func(ctx convey.C) {
token := &model.Token{
Mid: 88888970,
Token: "foo",
}
ctx.Convey("When everything gose positive", func(ctx convey.C) {
err := d.SetToken(context.TODO(), token)
ctx.So(err, convey.ShouldBeNil)
})
})
}
func TestDao_DelCache(t *testing.T) {
convey.Convey("DelCache", t, func(ctx convey.C) {
token := "foo"
ctx.Convey("When everything gose positive", func(ctx convey.C) {
err := d.DelCache(context.TODO(), token)
ctx.So(err, convey.ShouldBeNil)
})
})
}
func TestDao_NotifyGame(t *testing.T) {
convey.Convey("NotifyGame", t, func(ctx convey.C) {
var (
mid = &model.AccessInfo{}
action = ""
)
ctx.Convey("When everything gose positive", func(ctx convey.C) {
mock := monkey.PatchInstanceMethod(reflect.TypeOf(d.gameClient), "Get", func(d *bm.Client, _ context.Context, _, _ string, _ url.Values, _ interface{}) error {
return nil
})
defer mock.Unpatch()
err := d.NotifyGame(mid, action)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
})
mock2 := monkey.PatchInstanceMethod(reflect.TypeOf(d.gameClient), "Get", func(d *bm.Client, _ context.Context, _, _ string, _ url.Values, _ interface{}) error {
return ecode.Int(500)
})
defer mock2.Unpatch()
err = d.NotifyGame(mid, action)
ctx.Convey("Then err should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldNotBeNil)
})
})
})
}

View File

@@ -0,0 +1,66 @@
package dao
import (
"context"
"go-common/app/job/main/passport/conf"
"go-common/library/database/hbase.v2"
"go-common/library/database/sql"
"go-common/library/log"
bm "go-common/library/net/http/blademaster"
)
// Dao struct info of Dao.
type Dao struct {
c *conf.Config
logDB *sql.DB
asoDB *sql.DB
client *bm.Client
gameClient *bm.Client
loginLogHBase *hbase.Client
pwdLogHBase *hbase.Client
setTokenURI string
delCacheURI string
delGameCacheURI string
}
// New new a Dao and return.
func New(c *conf.Config) (d *Dao) {
d = &Dao{
c: c,
logDB: sql.NewMySQL(c.DB.Log),
asoDB: sql.NewMySQL(c.DB.ASO),
client: bm.NewClient(c.HTTPClient),
gameClient: bm.NewClient(c.Game.Client),
loginLogHBase: hbase.NewClient(c.HBase.LoginLog.Config),
pwdLogHBase: hbase.NewClient(c.HBase.PwdLog.Config),
setTokenURI: c.URI.SetToken,
delCacheURI: c.URI.DelCache,
delGameCacheURI: c.Game.DelCacheURI,
}
return d
}
// Ping ping check dao health.
func (d *Dao) Ping(c context.Context) (err error) {
if err = d.logDB.Ping(c); err != nil {
log.Info("dao.logDB.Ping() error(%v)", err)
}
return
}
// Close close dao.
func (d *Dao) Close() (err error) {
if d.logDB != nil {
d.logDB.Close()
}
if d.loginLogHBase != nil {
d.loginLogHBase.Close()
}
if d.pwdLogHBase != nil {
d.pwdLogHBase.Close()
}
return
}

View File

@@ -0,0 +1,81 @@
package dao
import (
"context"
"flag"
"math/big"
"net"
"os"
"reflect"
"testing"
"go-common/app/job/main/passport/conf"
"go-common/library/database/sql"
"github.com/bouk/monkey"
"github.com/smartystreets/goconvey/convey"
"go-common/library/database/hbase.v2"
)
var (
d *Dao
)
func TestMain(m *testing.M) {
if os.Getenv("DEPLOY_ENV") != "" {
flag.Set("app_id", "main.passport.passport-user-job")
flag.Set("conf_token", "f5c791689788882beaef2903735949ea")
flag.Set("tree_id", "3074")
flag.Set("conf_version", "docker-1")
flag.Set("deploy_env", "uat")
flag.Set("conf_host", "config.bilibili.co")
flag.Set("conf_path", "/tmp")
flag.Set("region", "sh")
flag.Set("zone", "sh001")
} else {
flag.Set("conf", "../cmd/passport-job.toml")
}
flag.Parse()
if err := conf.Init(); err != nil {
panic(err)
}
d = New(conf.Conf)
os.Exit(m.Run())
}
// InetAtoN convert ip addr to int64.
func InetAtoN(ip string) int64 {
ret := big.NewInt(0)
ret.SetBytes(net.ParseIP(ip).To4())
return ret.Int64()
}
func TestDaoPing(t *testing.T) {
var c = context.Background()
convey.Convey("Ping", t, func(ctx convey.C) {
err := d.Ping(c)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
})
})
}
func TestDaoClose(t *testing.T) {
convey.Convey("Close", t, func(ctx convey.C) {
monkey.PatchInstanceMethod(reflect.TypeOf(d.logDB), "Close", func(_ *sql.DB) error {
return nil
})
monkey.PatchInstanceMethod(reflect.TypeOf(d.loginLogHBase), "Close", func(_ *hbase.Client) error {
return nil
})
monkey.PatchInstanceMethod(reflect.TypeOf(d.pwdLogHBase), "Close", func(_ *hbase.Client) error {
return nil
})
defer monkey.UnpatchAll()
var err error
d.Close()
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
})
})
}

View File

@@ -0,0 +1,69 @@
package dao
import (
"bytes"
"context"
"encoding/binary"
"strconv"
"time"
"go-common/app/job/main/passport/model"
"go-common/library/log"
)
const (
_tLoginLog = "ugc:AsoLoginLog"
_fLoginLogInfo = "f"
_cLoginLogMid = "mid"
_cLoginLogTs = "ts"
_cLoginLogLoginIP = "ip"
_cLoginLogType = "t"
_cLoginLogServer = "s"
_int64Max = 0x7fffffffffffffff
)
// AddLoginLogHBase add login log.
func (d *Dao) AddLoginLogHBase(c context.Context, loginLog *model.LoginLog) (err error) {
fvs := make(map[string][]byte)
fvs[_cLoginLogMid] = []byte(strconv.FormatInt(loginLog.Mid, 10))
fvs[_cLoginLogTs] = []byte(strconv.FormatInt(loginLog.Timestamp, 10))
fvs[_cLoginLogLoginIP] = []byte(strconv.FormatInt(loginLog.LoginIP, 10))
fvs[_cLoginLogType] = []byte(strconv.FormatInt(loginLog.Type, 10))
fvs[_cLoginLogServer] = []byte(loginLog.Server)
values := map[string]map[string][]byte{_fLoginLogInfo: fvs}
key := rowKeyLoginLog(loginLog.Mid, loginLog.Timestamp)
ctx, cancel := context.WithTimeout(c, time.Duration(d.c.HBase.LoginLog.WriteTimeout))
defer cancel()
if _, err = d.loginLogHBase.PutStr(ctx, _tLoginLog, string(key), values); err != nil {
log.Error("dao.hbase.Put(%v) error(%v)", err)
}
return
}
// rowKeyLoginLog generate row key of login log.
func rowKeyLoginLog(mid, ts int64) (res []byte) {
buf := bytes.Buffer{}
b := make([]byte, 8)
// reverse mid bytes
binary.BigEndian.PutUint64(b, uint64(mid))
reverse(b)
buf.Write(b)
// (int64_max - ts) bytes
binary.BigEndian.PutUint64(b, uint64(_int64Max-ts))
buf.Write(b)
res = buf.Bytes()
return
}
func reverse(b []byte) {
l := len(b)
for i := 0; i < l/2; i++ {
t := b[i]
b[i] = b[l-1-i]
b[l-1-i] = t
}
}

View File

@@ -0,0 +1,83 @@
package dao
import (
"context"
"strconv"
"testing"
"time"
"go-common/app/job/main/passport/model"
"go-common/library/queue/databus"
xtime "go-common/library/time"
"github.com/smartystreets/goconvey/convey"
)
func TestDao_AddLoginLogHBase(t *testing.T) {
ts := time.Now().Unix()
mid := int64(88888970)
ipN := InetAtoN("127.0.0.1")
for i := 0; i < 6; i++ {
m := &model.LoginLog{
Mid: mid,
Timestamp: ts + int64(i),
LoginIP: int64(ipN),
Type: 1,
Server: strconv.FormatInt(int64(i), 10),
}
if err := d.AddLoginLogHBase(context.TODO(), m); err != nil {
t.Logf("dao.AddLoginLogHBase(%+v) error(%v)", m, err)
t.FailNow()
}
}
}
func TestDao_SendLoginLogMsgs(t *testing.T) {
convey.Convey("SetToken", t, func(ctx convey.C) {
dsPubConf := &databus.Config{
Key: "0QEO9F8JuuIxZzNDvklH",
Secret: "0QEO9F8JuuIxZzNDvklI",
Group: "PassportLog-Login-P",
Topic: "PassportLog-T",
Action: "pub",
Name: "databus",
Proto: "tcp",
Addr: "172.16.33.158:6205",
Active: 1,
Idle: 1,
DialTimeout: xtime.Duration(time.Second),
WriteTimeout: xtime.Duration(time.Second),
ReadTimeout: xtime.Duration(time.Second),
IdleTimeout: xtime.Duration(time.Minute),
}
dsPub := databus.New(dsPubConf)
defer dsPub.Close()
ts := time.Now().Unix()
mid := int64(88888970)
ipN := InetAtoN("127.0.0.1")
for i := 1; i <= 1; i++ {
v := &model.LoginLog{
Mid: mid,
Timestamp: ts + int64(i),
LoginIP: int64(ipN),
Type: 1,
Server: strconv.FormatInt(int64(i), 10),
}
k := dsPubConf.Topic + strconv.FormatInt(mid, 10)
if err := dsPub.Send(context.TODO(), k, v); err != nil {
t.Errorf("failed to send login log databus message, dsPub.Send(%v, %v) error(%v)", k, v, err)
t.FailNow()
}
}
})
}
func TestIntCast(t *testing.T) {
convey.Convey("when ts diff by delta, the uint32(_int64 - ts) diff should be the same", t, func(ctx convey.C) {
ts := time.Now().Unix()
delta := int64(10)
a := uint32(_int64Max - ts)
b := uint32(_int64Max - ts - delta)
ctx.So(a-b, convey.ShouldEqual, delta)
})
}

View File

@@ -0,0 +1,64 @@
package dao
import (
"bytes"
"context"
"encoding/binary"
"strconv"
"time"
"go-common/app/job/main/passport/model"
"go-common/library/log"
)
const (
_tPwdLog = "ugc:PwdLog"
_fPwdLog = "pwdlog"
_cPwdLogMid = "mid"
_cPwdLogOldPwd = "old_pwd"
_cPwdLogOldSalt = "old_salt"
_cPwdLogNewPwd = "new_pwd"
_cPwdLogNewSalt = "new_salt"
_cPwdLogIP = "ip"
_cPwdLogTs = "ts"
)
// AddPwdLogHBase add pwd log.
func (d *Dao) AddPwdLogHBase(c context.Context, pwdLog *model.PwdLog) (err error) {
fvs := make(map[string][]byte)
fvs[_cPwdLogMid] = []byte(strconv.FormatInt(pwdLog.Mid, 10))
fvs[_cPwdLogOldPwd] = []byte(pwdLog.OldPwd)
fvs[_cPwdLogOldSalt] = []byte(pwdLog.OldSalt)
fvs[_cPwdLogNewPwd] = []byte(pwdLog.NewPwd)
fvs[_cPwdLogNewSalt] = []byte(pwdLog.NewSalt)
fvs[_cPwdLogTs] = []byte(strconv.FormatInt(pwdLog.Timestamp, 10))
fvs[_cPwdLogIP] = []byte(strconv.FormatInt(pwdLog.IP, 10))
values := map[string]map[string][]byte{_fPwdLog: fvs}
key := rowKeyPwdLog(pwdLog.Mid, pwdLog.Timestamp)
ctx, cancel := context.WithTimeout(c, time.Duration(d.c.HBase.PwdLog.WriteTimeout))
defer cancel()
if _, err = d.pwdLogHBase.PutStr(ctx, _tPwdLog, string(key), values); err != nil {
log.Error("failed to put pwd log to hbase, dao.hbase.Put(%+v) error(%v)", pwdLog, err)
}
log.Info("Add pwdLog to HBase, (%+v)", pwdLog)
return
}
// rowKeyPwdLog generate row key of pwd log.
func rowKeyPwdLog(mid, ts int64) (res []byte) {
buf := bytes.Buffer{}
b := make([]byte, 8)
// reverse mid bytes
binary.BigEndian.PutUint64(b, uint64(mid))
reverse(b)
buf.Write(b)
// (int64_max - ts) bytes
binary.BigEndian.PutUint64(b, uint64(_int64Max-ts))
buf.Write(b)
res = buf.Bytes()
return
}

View File

@@ -0,0 +1,51 @@
package dao
import (
"context"
"fmt"
"reflect"
"testing"
"go-common/app/job/main/passport/model"
"go-common/library/database/hbase.v2"
"github.com/bouk/monkey"
"github.com/smartystreets/goconvey/convey"
"github.com/tsuna/gohbase/hrpc"
)
func TestDao_AddPwdLogHBase(t *testing.T) {
convey.Convey("AddPwdLogHBase", t, func(ctx convey.C) {
var (
c = context.Background()
a = &model.PwdLog{}
)
ctx.Convey("When everything gose positive", func(ctx convey.C) {
mock := monkey.PatchInstanceMethod(reflect.TypeOf(d.pwdLogHBase), "PutStr", func(_ *hbase.Client, _ context.Context, _, _ string, _ map[string]map[string][]byte, _ ...func(hrpc.Call) error) (res *hrpc.Result, err error) {
return nil, nil
})
defer mock.Unpatch()
err := d.AddPwdLogHBase(c, a)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
})
})
ctx.Convey("When error", func(ctx convey.C) {
mock := monkey.PatchInstanceMethod(reflect.TypeOf(d.pwdLogHBase), "PutStr", func(_ *hbase.Client, _ context.Context, _, _ string, _ map[string]map[string][]byte, _ ...func(hrpc.Call) error) (res *hrpc.Result, err error) {
return nil, fmt.Errorf("error")
})
defer mock.Unpatch()
err := d.AddPwdLogHBase(c, a)
ctx.Convey("Then err should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldNotBeNil)
})
})
})
}
func TestDao_rowKeyPwdLog(t *testing.T) {
convey.Convey("rowKeyPwdLog", t, func() {
res := rowKeyPwdLog(0, 0)
convey.So(res, convey.ShouldNotBeNil)
})
}

View File

@@ -0,0 +1,108 @@
package dao
import (
"context"
"fmt"
"strings"
"go-common/app/job/main/passport/model"
"go-common/library/database/sql"
"go-common/library/log"
)
const (
_insertLoginLog = "INSERT INTO aso_login_log%d(`mid`, `timestamp`, `loginip`, `type`, `server`) VALUES %s"
_queryTelBindLog = "SELECT id, mid, tel, timestamp FROM aso_telephone_bind_log where id = ?"
_queryEmailBindLog = "SELECT id, mid, email, timestamp FROM aso_email_bind_log where id = ?"
_batchGetPwdLog = "select id, timestamp, mid, ip, old_pwd, old_salt, new_pwd, new_salt from aso_pwd_log where id < ? order by id desc limit 1000"
_getPwdLog = "select id, timestamp, mid, ip, old_pwd, old_salt, new_pwd, new_salt from aso_pwd_log where id = ?"
)
// AddLoginLog insert service to db.
func (d *Dao) AddLoginLog(vs []*model.LoginLog) (err error) {
if len(vs) == 0 {
return
}
var args = make([]string, 0, len(vs))
for _, v := range vs {
args = append(args, fmt.Sprintf(`(%d,%d,%d,%d,'%s')`, v.Mid, v.Timestamp, v.LoginIP, v.Type, v.Server))
}
if len(args) == 0 {
return
}
s := fmt.Sprintf(_insertLoginLog, vs[0].Mid%10, strings.Join(args, ","))
if _, err = d.logDB.Exec(context.Background(), s); err != nil {
log.Error("d.logDB.Exec(%s) error(%v)", s, err)
}
return
}
// QueryTelBindLog query from id
func (d *Dao) QueryTelBindLog(id int64) (res *model.TelBindLog, err error) {
if id <= 0 {
return
}
res = new(model.TelBindLog)
row := d.asoDB.QueryRow(context.Background(), _queryTelBindLog, id)
if err = row.Scan(&res.ID, &res.Mid, &res.Tel, &res.Timestamp); err != nil {
if err == sql.ErrNoRows {
err = nil
return
}
log.Error("QueryTelBindLog err(%+v)", err)
return
}
return
}
// QueryEmailBindLog query from id
func (d *Dao) QueryEmailBindLog(id int64) (res *model.EmailBindLog, err error) {
if id <= 0 {
return
}
res = new(model.EmailBindLog)
row := d.asoDB.QueryRow(context.Background(), _queryEmailBindLog, id)
if err = row.Scan(&res.ID, &res.Mid, &res.Email, &res.Timestamp); err != nil {
if err == sql.ErrNoRows {
err = nil
return
}
log.Error("QueryEmailBindLog err(%+v)", err)
return
}
return
}
// BatchGetPwdLog batch get pwd log
func (d *Dao) BatchGetPwdLog(c context.Context, id int64) (res []*model.PwdLog, err error) {
var rows *sql.Rows
if rows, err = d.asoDB.Query(c, _batchGetPwdLog, id); err != nil {
log.Error("batch get pwd log, dao.db.Query(%s) error(%v)", _batchGetPwdLog, err)
return
}
defer rows.Close()
for rows.Next() {
pwd := new(model.PwdLog)
if err = rows.Scan(&pwd.ID, &pwd.Timestamp, &pwd.Mid, &pwd.IP, &pwd.OldPwd, &pwd.OldSalt, &pwd.NewPwd, &pwd.NewSalt); err != nil {
log.Error("row.Scan() error(%v)", err)
return
}
res = append(res, pwd)
}
return
}
// GetPwdLog get pwd log
func (d *Dao) GetPwdLog(c context.Context, id int64) (res *model.PwdLog, err error) {
res = new(model.PwdLog)
row := d.asoDB.QueryRow(c, _getPwdLog, id)
if err = row.Scan(&res.ID, &res.Timestamp, &res.Mid, &res.IP, &res.OldPwd, &res.OldSalt, &res.NewPwd, &res.NewSalt); err != nil {
if err == sql.ErrNoRows {
err = nil
return
}
log.Error("row.Scan() error(%v)", err)
return
}
return
}

View File

@@ -0,0 +1,69 @@
package dao
import (
"context"
"testing"
"time"
"go-common/app/job/main/passport/model"
"github.com/smartystreets/goconvey/convey"
)
func TestDao_AddLoginLog(t *testing.T) {
vs := make([]*model.LoginLog, 0)
v := &model.LoginLog{
Mid: 10,
LoginIP: InetAtoN("127.0.0.1"),
Timestamp: time.Now().Unix(),
Type: 1,
Server: "server",
}
for i := 0; i < 10; i++ {
vs = append(vs, v)
}
if err := d.AddLoginLog(vs); err != nil {
t.Errorf("dao.AddLoginLog(%v) error(%v)", vs, err)
t.FailNow()
}
}
func TestDao_QueryTelBindLog(t *testing.T) {
convey.Convey("", t, func() {
res, err := d.QueryTelBindLog(1)
convey.So(err, convey.ShouldBeNil)
convey.So(res, convey.ShouldNotBeNil)
convey.So(res.ID, convey.ShouldEqual, 1)
})
}
func TestDao_QueryEmailBindLog(t *testing.T) {
convey.Convey("", t, func() {
res, err := d.QueryEmailBindLog(1)
convey.So(err, convey.ShouldBeNil)
convey.So(res, convey.ShouldNotBeNil)
convey.So(res.ID, convey.ShouldEqual, 1)
})
}
func TestDao_BatchGetPwdLog(t *testing.T) {
convey.Convey("BatchGetPwdLog", t, func() {
var (
c = context.Background()
)
res, err := d.BatchGetPwdLog(c, 100000000)
convey.So(err, convey.ShouldBeNil)
convey.So(res, convey.ShouldNotBeNil)
})
}
func TestDao_GetPwdLog(t *testing.T) {
convey.Convey("GetPwdLog", t, func() {
var (
c = context.Background()
)
res, err := d.GetPwdLog(c, 1)
convey.So(err, convey.ShouldBeNil)
convey.So(res, convey.ShouldNotBeNil)
})
}