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,65 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_test",
"go_library",
)
go_test(
name = "go_default_test",
srcs = [
"dao_test.go",
"memcache_test.go",
"stat_test.go",
"task_log_test.go",
"task_test.go",
],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = [
"//app/admin/main/laser/conf:go_default_library",
"//app/admin/main/laser/model:go_default_library",
"//vendor/github.com/smartystreets/goconvey/convey:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = [
"dao.go",
"memcache.go",
"stat.go",
"task.go",
"task_log.go",
],
importpath = "go-common/app/admin/main/laser/dao",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/laser/conf:go_default_library",
"//app/admin/main/laser/model:go_default_library",
"//library/cache/memcache: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",
"//library/xstr:go_default_library",
"//vendor/github.com/pkg/errors: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,42 @@
package dao
import (
"context"
"go-common/app/admin/main/laser/conf"
"go-common/library/cache/memcache"
"go-common/library/database/sql"
bm "go-common/library/net/http/blademaster"
"time"
)
// Dao struct.
type Dao struct {
c *conf.Config
laserDB *sql.DB
mc *memcache.Pool
mcExpire int32
HTTPClient *bm.Client
}
// New Dao instance.
func New(c *conf.Config) (d *Dao) {
d = &Dao{
c: c,
laserDB: sql.NewMySQL(c.Mysql),
mc: memcache.NewPool(c.Memcache.Laser.Config),
mcExpire: int32(time.Duration(c.Memcache.Laser.Expire) / time.Second),
HTTPClient: bm.NewClient(c.HTTPClient),
}
return
}
// Ping check db connection.
func (d *Dao) Ping(c context.Context) (err error) {
return d.laserDB.Ping(c)
}
// Close dao resources.
func (d *Dao) Close(c context.Context) (err error) {
return d.laserDB.Close()
}

View File

@@ -0,0 +1,35 @@
package dao
import (
"flag"
"go-common/app/admin/main/laser/conf"
"os"
"testing"
)
var (
d *Dao
)
func TestMain(m *testing.M) {
if os.Getenv("DEPLOY_ENV") != "" {
flag.Set("app_id", "mobile.studio.laser-admin")
flag.Set("conf_token", "25911b439f4636ce9083f91c4882dffa")
flag.Set("tree_id", "19167")
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")
}
if os.Getenv("UT_LOCAL_TEST") != "" {
flag.Set("conf", "../../cmd/laser-admin.toml")
}
flag.Parse()
if err := conf.Init(); err != nil {
panic(err)
}
d = New(conf.Conf)
os.Exit(m.Run())
}

View File

@@ -0,0 +1,66 @@
package dao
import (
"context"
"go-common/app/admin/main/laser/model"
"go-common/library/cache/memcache"
"go-common/library/log"
"strconv"
)
const (
_prefix = "taskinfo_"
)
func keyTaskInfo(mid int64) string {
return _prefix + strconv.FormatInt(mid, 10)
}
// TaskInfoCache get taskInfo cache
func (d *Dao) TaskInfoCache(c context.Context, mid int64) (ti *model.TaskInfo, err error) {
var (
conn = d.mc.Get(c)
r *memcache.Item
)
defer conn.Close()
r, err = conn.Get(keyTaskInfo(mid))
if err != nil {
if err == memcache.ErrNotFound {
err = nil
} else {
log.Error("conn Get2(%d) error(%v)", mid, err)
}
return
}
if err = conn.Scan(r, &ti); err != nil {
log.Error("json.Unmarshal(%s) error(%v)", r.Value, err)
ti = nil
}
return
}
// AddTaskInfoCache add taskInfo cache
func (d *Dao) AddTaskInfoCache(c context.Context, mid int64, ti *model.TaskInfo) (err error) {
var (
key = keyTaskInfo(mid)
)
conn := d.mc.Get(c)
defer conn.Close()
if err = conn.Set(&memcache.Item{Key: key, Object: ti, Flags: memcache.FlagJSON, Expiration: d.mcExpire}); err != nil {
log.Error("memcache.Set(%v) error(%v)", key, err)
}
return
}
// RemoveTaskInfoCache remove taskInfo cache
func (d *Dao) RemoveTaskInfoCache(c context.Context, mid int64) (err error) {
var (
key = keyTaskInfo(mid)
)
conn := d.mc.Get(c)
defer conn.Close()
if err = conn.Delete(key); err != nil {
log.Error("memcache.Delete(%v) error(%v)", key, err)
}
return
}

View File

@@ -0,0 +1,68 @@
package dao
import (
"context"
"go-common/app/admin/main/laser/model"
"testing"
"github.com/smartystreets/goconvey/convey"
)
func TestDaokeyTaskInfo(t *testing.T) {
convey.Convey("keyTaskInfo", t, func(ctx convey.C) {
var (
mid = int64(0)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
p1 := keyTaskInfo(mid)
ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
ctx.So(p1, convey.ShouldNotBeNil)
})
})
})
}
func TestDaoTaskInfoCache(t *testing.T) {
convey.Convey("TaskInfoCache", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(0)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
d.TaskInfoCache(c, mid)
ctx.Convey("Then err should be nil.ti should not be nil.", func(ctx convey.C) {
})
})
})
}
func TestDaoAddTaskInfoCache(t *testing.T) {
convey.Convey("AddTaskInfoCache", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(0)
ti = &model.TaskInfo{}
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
d.AddTaskInfoCache(c, mid, ti)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
})
})
})
}
func TestDaoRemoveTaskInfoCache(t *testing.T) {
convey.Convey("RemoveTaskInfoCache", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(0)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
d.RemoveTaskInfoCache(c, mid)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
})
})
})
}

View File

@@ -0,0 +1,151 @@
package dao
import (
"context"
"fmt"
"time"
"go-common/app/admin/main/laser/model"
"go-common/library/ecode"
"go-common/library/log"
"go-common/library/xstr"
"net/url"
)
const (
_UrlUnames = "/x/admin/manager/users/unames"
_UrlUids = "/x/admin/manager/users/uids"
_queryArchiveStatSQL = " SELECT stat_date, business, stat_type, typeid, uid, stat_value FROM archive_stat WHERE stat_date = '%s' AND business = %d %s "
_queryArchiveAuditCargoSQL = " SELECT uid, stat_date, receive_value, audit_value FROM archive_audit_cargo_hour %s "
_queryArchiveStatStreamSQL = " SELECT stat_time, business, stat_type, typeid, uid, stat_value FROM archive_stat_stream WHERE stat_time = '%s' AND business = %d %s "
)
// StatArchiveStat is stat archive data.
func (d *Dao) StatArchiveStat(c context.Context, business int, typeIDS []int64, uids []int64, statTypes []int64, statDate time.Time) (statNodes []*model.StatNode, err error) {
var queryStmt string
if len(statTypes) != 0 {
queryStmt = queryStmt + fmt.Sprintf(" And stat_type in ( %s ) ", xstr.JoinInts(statTypes))
}
if len(typeIDS) != 0 {
queryStmt = queryStmt + fmt.Sprintf(" AND typeid IN ( %s ) ", xstr.JoinInts(typeIDS))
}
if len(uids) != 0 {
queryStmt = queryStmt + fmt.Sprintf(" AND uid IN ( %s ) ", xstr.JoinInts(uids))
}
rows, err := d.laserDB.Query(c, fmt.Sprintf(_queryArchiveStatSQL, statDate.Format("2006-01-02"), business, queryStmt))
if err != nil {
log.Error("d.laserDB.Query() error(%v)", err)
return
}
defer rows.Close()
for rows.Next() {
item := &model.StatNode{}
if err = rows.Scan(&item.StatDate, &item.Business, &item.StatType, &item.TypeID, &item.UID, &item.StatValue); err != nil {
log.Error("rows.Scan() error(%v)", err)
return
}
statNodes = append(statNodes, item)
}
return
}
// QueryArchiveCargo is query archive audit and receive value.
func (d *Dao) QueryArchiveCargo(c context.Context, statTime time.Time, uids []int64) (items []*model.CargoDetail, err error) {
whereStmt := fmt.Sprintf(" WHERE stat_date = '%s' ", statTime.Format("2006-01-02 15:04:05"))
if len(uids) != 0 {
uidStr := xstr.JoinInts(uids)
whereStmt = whereStmt + fmt.Sprintf(" AND uid in ( %s ) ", uidStr)
}
rows, err := d.laserDB.Query(c, fmt.Sprintf(_queryArchiveAuditCargoSQL, whereStmt))
if err != nil {
log.Error("d.laserDB.Query() error(%v)", err)
return
}
defer rows.Close()
for rows.Next() {
item := &model.CargoDetail{}
if err = rows.Scan(&item.UID, &item.StatDate, &item.ReceiveValue, &item.AuditValue); err != nil {
log.Error("rows.Scan() error(%v)", err)
return
}
items = append(items, item)
}
return
}
//GetUIDByNames is query uids by uname array separated by comma.
func (d *Dao) GetUIDByNames(c context.Context, unames string) (res map[string]int64, err error) {
var param = url.Values{}
param.Set("unames", unames)
var httpRes struct {
Code int `json:"code"`
Data map[string]int64 `json:"data"`
Message string `json:"message"`
}
err = d.HTTPClient.Get(c, d.c.Host.Manager+_UrlUids, "", param, &httpRes)
if err != nil {
log.Error("d.client.Get(%s) error(%v)", d.c.Host.Manager+_UrlUids+"?"+param.Encode(), err)
return
}
if httpRes.Code != ecode.OK.Code() {
log.Error("url(%s) error(%v), code(%d), message(%s)", d.c.Host.Manager+_UrlUids+"?"+param.Encode(), err, httpRes.Code, httpRes.Message)
}
res = httpRes.Data
return
}
//GetUNamesByUids is query usernames by uids.
func (d *Dao) GetUNamesByUids(c context.Context, uids []int64) (res map[int64]string, err error) {
var param = url.Values{}
var uidStr = xstr.JoinInts(uids)
param.Set("uids", uidStr)
var httpRes struct {
Code int `json:"code"`
Data map[int64]string `json:"data"`
Message string `json:"message"`
}
err = d.HTTPClient.Get(c, d.c.Host.Manager+_UrlUnames, "", param, &httpRes)
if err != nil {
log.Error("d.client.Get(%s) error(%v)", d.c.Host.Manager+_UrlUnames+"?"+param.Encode(), err)
return
}
if httpRes.Code != 0 {
log.Error("url(%s) error(%v), code(%d), message(%s)", d.c.Host.Manager+_UrlUnames+"?"+param.Encode(), err, httpRes.Code, httpRes.Message)
}
res = httpRes.Data
return
}
// StatArchiveStatStream is stat archive data.
func (d *Dao) StatArchiveStatStream(c context.Context, business int, typeIDS []int64, uids []int64, statTypes []int64, statDate time.Time) (statNodes []*model.StatNode, err error) {
var queryStmt string
if len(statTypes) != 0 {
queryStmt = queryStmt + fmt.Sprintf(" And stat_type in ( %s ) ", xstr.JoinInts(statTypes))
}
if len(typeIDS) != 0 {
queryStmt = queryStmt + fmt.Sprintf(" AND typeid IN ( %s ) ", xstr.JoinInts(typeIDS))
}
if len(uids) != 0 {
queryStmt = queryStmt + fmt.Sprintf(" AND uid IN ( %s ) ", xstr.JoinInts(uids))
}
rows, err := d.laserDB.Query(c, fmt.Sprintf(_queryArchiveStatStreamSQL, statDate.Format("2006-01-02"), business, queryStmt))
if err != nil {
log.Error("d.laserDB.Query() error(%v)", err)
return
}
defer rows.Close()
for rows.Next() {
node := &model.StatNode{}
if err = rows.Scan(&node.StatDate, &node.Business, &node.StatType, &node.TypeID, &node.UID, &node.StatValue); err != nil {
log.Error("rows.Scan() error(%v)", err)
return
}
statNodes = append(statNodes, node)
}
return
}

View File

@@ -0,0 +1,93 @@
package dao
import (
"context"
"testing"
"time"
"github.com/smartystreets/goconvey/convey"
)
func TestDaoStatArchiveStat(t *testing.T) {
convey.Convey("StatArchiveStat", t, func(convCtx convey.C) {
var (
c = context.Background()
business = int(0)
typeIDS = []int64{}
uids = []int64{}
statTypes = []int64{}
statDate = time.Now()
)
convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
d.StatArchiveStat(c, business, typeIDS, uids, statTypes, statDate)
convCtx.Convey("Then err should be nil.statNodes should not be nil.", func(convCtx convey.C) {
})
})
})
}
func TestDaoQueryArchiveCargo(t *testing.T) {
convey.Convey("QueryArchiveCargo", t, func(convCtx convey.C) {
var (
c = context.Background()
statTime = time.Now()
uids = []int64{}
)
convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
d.QueryArchiveCargo(c, statTime, uids)
convCtx.Convey("Then err should be nil.items should not be nil.", func(convCtx convey.C) {
})
})
})
}
func TestDaoGetUIDByNames(t *testing.T) {
convey.Convey("GetUIDByNames", t, func(convCtx convey.C) {
var (
c = context.Background()
unames = ""
)
convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
d.GetUIDByNames(c, unames)
convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
})
})
})
}
func TestDaoGetUNamesByUids(t *testing.T) {
convey.Convey("GetUNamesByUids", t, func(convCtx convey.C) {
var (
c = context.Background()
uids = []int64{}
)
convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
d.GetUNamesByUids(c, uids)
convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
})
})
})
}
func TestDaoStatArchiveStatStream(t *testing.T) {
convey.Convey("StatArchiveStatStream", t, func(convCtx convey.C) {
var (
c = context.Background()
business = int(0)
typeIDS = []int64{}
uids = []int64{}
statTypes = []int64{}
statDate = time.Now()
)
convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
d.StatArchiveStatStream(c, business, typeIDS, uids, statTypes, statDate)
convCtx.Convey("Then err should be nil.statNodes should not be nil.", func(convCtx convey.C) {
})
})
})
}

View File

@@ -0,0 +1,102 @@
package dao
import (
"go-common/library/log"
"context"
"fmt"
"github.com/pkg/errors"
"go-common/app/admin/main/laser/model"
"go-common/library/database/sql"
)
const (
_findMIDTaskSQL = " SELECT id, admin_id, username, mid, log_date, contact_email, source_type, platform, state, is_deleted, ctime, mtime FROM task WHERE mid = ? AND state = ? and is_deleted = 0"
_queryTaskInfoByIDSQL = " SELECT mid, log_date, source_type, platform FROM task WHERE state = 0 AND is_deleted = 0 AND id = ? "
_insertTaskSQL = " INSERT INTO task (mid, admin_id, username, log_date, contact_email, platform, source_type) VALUES (?, ?, ?, ?, ?, ?, ?) "
_deleteTaskSQL = " UPDATE task SET is_deleted = 1 , username = ? , admin_id = ? WHERE id = ? AND is_deleted = 0 "
_countTaskSQL = " SELECT count(*) FROM task WHERE %s "
_queryTaskSQL = " SELECT id, admin_id, username, mid, log_date, contact_email, source_type, platform, state, is_deleted, ctime, mtime FROM task WHERE %s ORDER BY %s LIMIT %d,%d "
_updateTaskSQL = " UPDATE task SET %s WHERE id = ? AND is_deleted = 0 AND state = ? "
)
// AddTask is add a unique task by mid and state(0).
func (d *Dao) AddTask(ctx context.Context, mid int64, username string, adminID int64, logDate string, contactEmail string, platform int, sourceType int) (lastInsertID int64, err error) {
res, err := d.laserDB.Exec(ctx, _insertTaskSQL, mid, adminID, username, logDate, contactEmail, platform, sourceType)
if err != nil {
log.Error("d.AddTask() error(%v)", err)
}
return res.LastInsertId()
}
// FindTask is find task by mid and state.
func (d *Dao) FindTask(context context.Context, mid int64, state int) (t *model.Task, err error) {
t = &model.Task{}
row := d.laserDB.QueryRow(context, _findMIDTaskSQL, mid, state)
if err = row.Scan(&t.ID, &t.AdminID, &t.Username, &t.MID, &t.LogDate, &t.ContactEmail, &t.SourceType, &t.Platform, &t.State, &t.IsDeleted, &t.CTime, &t.MTime); err != nil {
if err == sql.ErrNoRows {
t = nil
err = nil
return
}
log.Error("row.Scan() error(%v)", err)
}
return
}
// QueryTaskInfoByIDSQL is query task by task id.
func (d *Dao) QueryTaskInfoByIDSQL(c context.Context, id int64) (t *model.TaskInfo, err error) {
t = &model.TaskInfo{}
row := d.laserDB.QueryRow(c, _queryTaskInfoByIDSQL, id)
if err = row.Scan(&t.MID, &t.LogDate, &t.SourceType, &t.Platform); err != nil {
if err == sql.ErrNoRows {
t = nil
err = nil
} else {
err = errors.WithStack(err)
log.Error("row.Scan() error(%v)", err)
}
}
return
}
// DeleteTask is delete task by TaskID.
func (d *Dao) DeleteTask(ctx context.Context, taskID int64, username string, adminID int64) (err error) {
_, err = d.laserDB.Exec(ctx, _deleteTaskSQL, username, adminID, taskID)
if err != nil {
log.Error("d.DeleteTask() error(%v)", err)
}
return
}
// UpdateTask is update undone task where state = 0.
func (d *Dao) UpdateTask(ctx context.Context, taskID int64, state int, updateStmt string) (err error) {
_, err = d.laserDB.Exec(ctx, fmt.Sprintf(_updateTaskSQL, updateStmt), taskID, state)
if err != nil {
log.Error("d.UpdateTask() error(%v)", err)
}
return
}
// QueryTask is query task by condition.
func (d *Dao) QueryTask(ctx context.Context, queryStmt string, sort string, offset int, limit int) (tasks []*model.Task, count int64, err error) {
row := d.laserDB.QueryRow(ctx, fmt.Sprintf(_countTaskSQL, queryStmt))
if err = row.Scan(&count); err != nil {
return
}
rows, err := d.laserDB.Query(ctx, fmt.Sprintf(_queryTaskSQL, queryStmt, sort, offset, limit))
if err != nil {
log.Error("d.Query() error(%v)", err)
return
}
defer rows.Close()
for rows.Next() {
item := &model.Task{}
if err = rows.Scan(&item.ID, &item.AdminID, &item.Username, &item.MID, &item.LogDate, &item.ContactEmail, &item.SourceType, &item.Platform, &item.State, &item.IsDeleted, &item.CTime, &item.MTime); err != nil {
return
}
tasks = append(tasks, item)
}
return
}

View File

@@ -0,0 +1,32 @@
package dao
import (
"context"
"fmt"
"go-common/app/admin/main/laser/model"
)
const (
_countTaskLogSQL = "SELECT count(*) FROM task_log %s"
_queryTaskLogSQL = "SELECT * FROM task_log %s ORDER BY %s LIMIT %d, %d"
)
// QueryTaskLog is query finished task.
func (d *Dao) QueryTaskLog(ctx context.Context, queryStmt string, sort string, offset int, limit int) (taskLogs []*model.TaskLog, count int64, err error) {
row := d.laserDB.QueryRow(ctx, fmt.Sprintf(_countTaskLogSQL, queryStmt))
if err = row.Scan(&count); err != nil {
return
}
rows, err := d.laserDB.Query(ctx, fmt.Sprintf(_queryTaskLogSQL, queryStmt, sort, offset, limit))
if err != nil {
return
}
for rows.Next() {
t := &model.TaskLog{}
if err = rows.Scan(&t.ID, &t.TaskID, &t.MID, &t.Build, &t.Platform, &t.TaskState, &t.Reason, &t.CTime, &t.MTime); err != nil {
return
}
taskLogs = append(taskLogs, t)
}
return
}

View File

@@ -0,0 +1,26 @@
package dao
import (
"context"
"testing"
"github.com/smartystreets/goconvey/convey"
)
func TestDaoQueryTaskLog(t *testing.T) {
convey.Convey("QueryTaskLog", t, func(ctx convey.C) {
var (
c = context.Background()
queryStmt = ""
sort = "ctime"
offset = int(1)
limit = int(10)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
d.QueryTaskLog(c, queryStmt, sort, offset, limit)
ctx.Convey("Then err should be nil.taskLogs,count should not be nil.", func(ctx convey.C) {
})
})
})
}

View File

@@ -0,0 +1,112 @@
package dao
import (
"context"
"testing"
"github.com/smartystreets/goconvey/convey"
)
func TestDaoAddTask(t *testing.T) {
convey.Convey("AddTask", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(2233)
username = "yanjinbin"
adminID = int64(479)
logDate = "2018-11-28 20:19:09"
contactEmail = "yanjinbin@qq.com"
platform = int(1)
sourceType = int(1)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
d.AddTask(c, mid, username, adminID, logDate, contactEmail, platform, sourceType)
ctx.Convey("Then err should be nil.lastInsertID should not be nil.", func(ctx convey.C) {
})
})
})
}
func TestDaoFindTask(t *testing.T) {
convey.Convey("FindTask", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(0)
state = int(0)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
d.FindTask(c, mid, state)
ctx.Convey("Then err should be nil.no should not be nil.", func(ctx convey.C) {
})
})
})
}
func TestDaoQueryTaskInfoByIDSQL(t *testing.T) {
convey.Convey("QueryTaskInfoByIDSQL", t, func(ctx convey.C) {
var (
c = context.Background()
id = int64(0)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
d.QueryTaskInfoByIDSQL(c, id)
ctx.Convey("Then err should be nil.no should not be nil.", func(ctx convey.C) {
})
})
})
}
func TestDaoDeleteTask(t *testing.T) {
convey.Convey("DeleteTask", t, func(ctx convey.C) {
var (
c = context.Background()
taskID = int64(0)
username = ""
adminID = int64(0)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
err := d.DeleteTask(c, taskID, username, adminID)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
})
})
})
}
func TestDaoUpdateTask(t *testing.T) {
convey.Convey("UpdateTask", t, func(ctx convey.C) {
var (
c = context.Background()
taskID = int64(0)
state = int(0)
updateStmt = ""
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
d.UpdateTask(c, taskID, state, updateStmt)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
})
})
})
}
func TestDaoQueryTask(t *testing.T) {
convey.Convey("QueryTask", t, func(ctx convey.C) {
var (
c = context.Background()
queryStmt = ""
sort = ""
offset = int(0)
limit = int(0)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
d.QueryTask(c, queryStmt, sort, offset, limit)
ctx.Convey("Then err should be nil.tasks,count should not be nil.", func(ctx convey.C) {
})
})
})
}