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,63 @@
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",
"http_test.go",
"mc_test.go",
"mysql_test.go",
],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = [
"//app/admin/main/member/conf:go_default_library",
"//app/admin/main/member/model/block:go_default_library",
"//library/cache/memcache:go_default_library",
"//library/database/sql:go_default_library",
"//library/net/http/blademaster:go_default_library",
"//vendor/github.com/smartystreets/goconvey/convey:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = [
"dao.go",
"http.go",
"mc.go",
"mysql.go",
],
importpath = "go-common/app/admin/main/member/dao/block",
tags = ["automanaged"],
deps = [
"//app/admin/main/member/conf:go_default_library",
"//app/admin/main/member/model/block:go_default_library",
"//library/cache/memcache:go_default_library",
"//library/database/sql:go_default_library",
"//library/ecode:go_default_library",
"//library/net/http/blademaster: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,53 @@
package block
import (
"context"
"go-common/app/admin/main/member/conf"
"go-common/library/cache/memcache"
xsql "go-common/library/database/sql"
bm "go-common/library/net/http/blademaster"
"github.com/pkg/errors"
)
// Dao .
type Dao struct {
conf *conf.Config
mc *memcache.Pool
db *xsql.DB
httpClient *bm.Client
}
// New init mysql db
func New(conf *conf.Config, client *bm.Client, mc *memcache.Pool, db *xsql.DB) (dao *Dao) {
dao = &Dao{
conf: conf,
mc: mc,
db: db,
httpClient: client,
}
return
}
// BeginTX .
func (d *Dao) BeginTX(c context.Context) (tx *xsql.Tx, err error) {
if tx, err = d.db.Begin(c); err != nil {
err = errors.WithStack(err)
}
return
}
// Close close the resource.
func (d *Dao) Close() {
d.mc.Close()
d.db.Close()
}
// Ping dao ping
func (d *Dao) Ping(c context.Context) (err error) {
if err = d.db.Ping(c); err != nil {
return
}
return
}

View File

@@ -0,0 +1,39 @@
package block
import (
"flag"
"os"
"testing"
"go-common/app/admin/main/member/conf"
"go-common/library/cache/memcache"
xsql "go-common/library/database/sql"
bm "go-common/library/net/http/blademaster"
)
var (
d *Dao
)
func TestMain(m *testing.M) {
if os.Getenv("DEPLOY_ENV") != "" {
flag.Set("app_id", "main.account.member-admin")
flag.Set("conf_token", "c18eac2285e4e4a75a8672139c30d464")
flag.Set("tree_id", "2135")
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/member-admin-test.toml")
}
flag.Parse()
if err := conf.Init(); err != nil {
panic(err)
}
hc := bm.NewClient(conf.Conf.HTTPClient.Read)
d = New(conf.Conf, hc, memcache.NewPool(conf.Conf.BlockMemcache), xsql.NewMySQL(conf.Conf.BlockMySQL))
os.Exit(m.Run())
}

View File

@@ -0,0 +1,203 @@
package block
import (
"context"
"fmt"
"net/url"
"strings"
"time"
model "go-common/app/admin/main/member/model/block"
"go-common/library/ecode"
"github.com/pkg/errors"
)
// BlackhouseBlock .
func (d *Dao) BlackhouseBlock(c context.Context, p *model.ParamBatchBlock) (err error) {
midStrs := make([]string, len(p.MIDs))
for i, mid := range p.MIDs {
midStrs[i] = fmt.Sprintf("%d", mid)
}
params := url.Values{}
params.Set("mids", strings.Join(midStrs, ","))
params.Set("oper_id", fmt.Sprintf("%d", p.AdminID))
params.Set("operator_name", p.AdminName)
params.Set("blocked_days", fmt.Sprintf("%d", p.Duration))
switch p.Action {
case model.BlockActionForever:
params.Set("blocked_forever", "1")
params.Set("punish_type", "3")
default:
params.Set("blocked_forever", "0")
params.Set("punish_type", "2")
}
params.Set("blocked_remark", p.Comment)
params.Set("origin_type", fmt.Sprintf("%d", p.Area))
params.Set("punish_time", fmt.Sprintf("%d", time.Now().Unix()))
params.Set("reason_type", fmt.Sprintf("%d", parseReasonType(p.Reason)))
var res struct {
Code int `json:"code"`
}
if err = d.httpClient.Post(c, d.conf.BlockProperty.BlackHouseURL, "", params, &res); err != nil {
err = errors.WithStack(err)
return
}
if res.Code != 0 {
err = errors.WithStack(ecode.Int(res.Code))
return
}
return
}
func parseReasonType(msg string) (t int) {
switch msg {
case "刷屏":
t = 1
case "抢楼":
t = 2
case "发布色情低俗信息":
t = 3
case "发布赌博诈骗信息":
t = 4
case "发布违禁相关信息", "发布违禁信息":
t = 5
case "发布垃圾广告信息":
t = 6
case "发布人身攻击言论":
t = 7
case "发布侵犯他人隐私信息":
t = 8
case "发布引战言论":
t = 9
case "发布剧透信息":
t = 10
case "恶意添加无关标签":
t = 11
case "恶意删除他人标签":
t = 12
case "发布色情信息":
t = 13
case "发布低俗信息":
t = 14
case "发布暴力血腥信息":
t = 15
case "涉及恶意投稿行为":
t = 16
case "发布非法网站信息":
t = 17
case "发布传播不实信息":
t = 18
case "发布怂恿教唆信息":
t = 19
case "恶意刷屏":
t = 20
case "账号违规":
t = 21
case "恶意抄袭":
t = 22
case "冒充自制原创":
t = 23
case "发布青少年不良内容":
t = 24
case "破坏网络安全":
t = 25
case "发布虚假误导信息":
t = 26
case "仿冒官方认证账号":
t = 27
case "发布不适宜内容":
t = 28
case "违反运营规则":
t = 29
case "恶意创建话题":
t = 30
case "发布违规抽奖":
t = 31
case "恶意冒充他人":
t = 32
default:
t = 0
}
return
}
// SendSysMsg send sys msg.
func (d *Dao) SendSysMsg(c context.Context, code string, mids []int64, title string, content string, remoteIP string) (err error) {
params := url.Values{}
params.Set("mc", code)
params.Set("title", title)
params.Set("data_type", "4")
params.Set("context", content)
params.Set("mid_list", midsToParam(mids))
var res struct {
Code int `json:"code"`
Data *struct {
Status int8 `json:"status"`
Remark string `json:"remark"`
} `json:"data"`
}
if err = d.httpClient.Post(c, d.conf.BlockProperty.MSGURL, remoteIP, params, &res); err != nil {
err = errors.WithStack(err)
return
}
if res.Code != 0 {
err = errors.WithStack(ecode.Int(res.Code))
return
}
return
}
func midsToParam(mids []int64) (str string) {
strs := make([]string, 0, len(mids))
for _, mid := range mids {
strs = append(strs, fmt.Sprintf("%d", mid))
}
return strings.Join(strs, ",")
}
// TelInfo tel info.
func (d *Dao) TelInfo(c context.Context, mid int64) (tel string, err error) {
params := url.Values{}
params.Set("mid", fmt.Sprintf("%d", mid))
var resp struct {
Code int `json:"code"`
Data struct {
Mid int64 `json:"mid"`
Tel string `json:"tel"`
JoinIP string `json:"join_ip"`
JoinTime int64 `json:"join_time"`
} `json:"data"`
}
if err = d.httpClient.Get(c, d.conf.BlockProperty.TelURL, "", params, &resp); err != nil {
err = errors.Wrapf(err, "telinfo : %d", mid)
return
}
if resp.Code != 0 {
err = errors.Errorf("telinfo url(%s) res(%+v) err(%+v)", d.conf.BlockProperty.TelURL+"?"+params.Encode(), resp, ecode.Int(resp.Code))
return
}
tel = resp.Data.Tel
return
}
// MailInfo .
func (d *Dao) MailInfo(c context.Context, mid int64) (mail string, err error) {
params := url.Values{}
params.Set("mid", fmt.Sprintf("%d", mid))
var resp struct {
Code int `json:"code"`
Data string `json:"data"`
}
if err = d.httpClient.Get(c, d.conf.BlockProperty.MailURL, "", params, &resp); err != nil {
err = errors.Wrapf(err, "mailinfo : %d", mid)
return
}
if resp.Code != 0 {
err = errors.Errorf("mailinfo url(%s) res(%+v) err(%+v)", d.conf.BlockProperty.MailURL+"?"+params.Encode(), resp, ecode.Int(resp.Code))
return
}
mail = resp.Data
return
}

View File

@@ -0,0 +1,103 @@
package block
import (
"context"
model "go-common/app/admin/main/member/model/block"
"testing"
"github.com/smartystreets/goconvey/convey"
)
func TestBlockBlackhouseBlock(t *testing.T) {
convey.Convey("BlackhouseBlock", t, func(ctx convey.C) {
var (
c = context.Background()
p = &model.ParamBatchBlock{}
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
err := d.BlackhouseBlock(c, p)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldNotBeNil)
})
})
})
}
func TestBlockparseReasonType(t *testing.T) {
convey.Convey("parseReasonType", t, func(ctx convey.C) {
var (
msg = ""
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
no := parseReasonType(msg)
ctx.Convey("Then no should not be nil.", func(ctx convey.C) {
ctx.So(no, convey.ShouldNotBeNil)
})
})
})
}
func TestBlockSendSysMsg(t *testing.T) {
convey.Convey("SendSysMsg", t, func(ctx convey.C) {
var (
c = context.Background()
code = ""
mids = []int64{}
title = ""
content = ""
remoteIP = ""
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
err := d.SendSysMsg(c, code, mids, title, content, remoteIP)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldNotBeNil)
})
})
})
}
func TestBlockmidsToParam(t *testing.T) {
convey.Convey("midsToParam", t, func(ctx convey.C) {
var (
mids = []int64{}
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
str := midsToParam(mids)
ctx.Convey("Then str should not be nil.", func(ctx convey.C) {
ctx.So(str, convey.ShouldNotBeNil)
})
})
})
}
func TestBlockTelInfo(t *testing.T) {
convey.Convey("TelInfo", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(0)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
tel, err := d.TelInfo(c, mid)
ctx.Convey("Then err should be nil.tel should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldNotBeNil)
ctx.So(tel, convey.ShouldEqual, "")
})
})
})
}
func TestBlockMailInfo(t *testing.T) {
convey.Convey("MailInfo", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(0)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
mail, err := d.MailInfo(c, mid)
ctx.Convey("Then err should be nil.mail should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldNotBeNil)
ctx.So(mail, convey.ShouldEqual, "")
})
})
})
}

View File

@@ -0,0 +1,49 @@
package block
import (
"context"
"fmt"
"go-common/library/cache/memcache"
"github.com/pkg/errors"
)
func userKey(mid int64) (key string) {
key = fmt.Sprintf("u_%d", mid)
return
}
func userDetailKey(mid int64) (key string) {
key = fmt.Sprintf("ud_%d", mid)
return
}
// DeleteUserCache .
func (d *Dao) DeleteUserCache(c context.Context, mid int64) (err error) {
var (
key = userKey(mid)
conn = d.mc.Get(c)
)
defer conn.Close()
if err = conn.Delete(key); err != nil {
if err == memcache.ErrNotFound {
err = nil
return
}
err = errors.Wrapf(err, "key : %s", key)
return
}
return
}
// DeleteUserDetailCache delete user detail cache
func (d *Dao) DeleteUserDetailCache(c context.Context, mid int64) (err error) {
var (
key = userDetailKey(mid)
conn = d.mc.Get(c)
)
defer conn.Close()
err = conn.Delete(key)
return
}

View File

@@ -0,0 +1,37 @@
package block
import (
"context"
"testing"
"github.com/smartystreets/goconvey/convey"
)
func TestBlockuserKey(t *testing.T) {
convey.Convey("userKey", t, func(ctx convey.C) {
var (
mid = int64(46333)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
key := userKey(mid)
ctx.Convey("Then key should not be nil.", func(ctx convey.C) {
ctx.So(key, convey.ShouldEqual, "u_46333")
})
})
})
}
func TestBlockDeleteUserCache(t *testing.T) {
convey.Convey("DeleteUserCache", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(1)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
err := d.DeleteUserCache(c, mid)
ctx.Convey("test DeleteUserCache", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
})
})
})
}

View File

@@ -0,0 +1,180 @@
package block
import (
"context"
"fmt"
"strings"
model "go-common/app/admin/main/member/model/block"
xsql "go-common/library/database/sql"
"github.com/pkg/errors"
)
const (
_user = `SELECT id,mid,status,ctime,mtime FROM block_user WHERE mid=? LIMIT 1`
_users = `SELECT id,mid,status,ctime,mtime FROM block_user WHERE mid IN (%s)`
_upsertUser = `INSERT INTO block_user (mid,status) VALUES (?,?) ON DUPLICATE KEY UPDATE status=?`
_userDetails = `SELECT id,mid,block_count,ctime,mtime FROM block_user_detail WHERE mid IN (%s)`
_addAddBlockCount = `INSERT INTO block_user_detail (mid,block_count) VALUES (?,1) ON DUPLICATE KEY UPDATE block_count=block_count+1`
_history = `SELECT id,mid,admin_id,admin_name,source,area,reason,comment,action,start_time,
duration,notify,ctime,mtime FROM block_history_%d WHERE mid=? ORDER BY mtime %s LIMIT ?,? `
_historyCount = `SELECT count(*) FROM block_history_%d WHERE mid=? LIMIT 1`
_insertHistory = `INSERT INTO block_history_%d (mid,admin_id,admin_name,source,area,reason,comment,action,start_time,duration,notify) VALUES (?,?,?,?,?,?,?,?,?,?,?)`
)
func historyIdx(mid int64) int64 {
return mid % 10
}
// User .
func (d *Dao) User(c context.Context, mid int64) (user *model.DBUser, err error) {
user = &model.DBUser{}
row := d.db.QueryRow(c, _user, mid)
if err = row.Scan(&user.ID, &user.MID, &user.Status, &user.CTime, &user.MTime); err != nil {
err = nil
user = nil
return
}
return
}
// Users .
func (d *Dao) Users(c context.Context, mids []int64) (users []*model.DBUser, err error) {
if len(mids) == 0 {
return
}
var (
sql = fmt.Sprintf(_users, strings.Join(intsToStrs(mids), ","))
rows *xsql.Rows
)
if rows, err = d.db.Query(c, sql); err != nil {
err = errors.WithStack(err)
return
}
defer rows.Close()
for rows.Next() {
user := &model.DBUser{}
if err = rows.Scan(&user.ID, &user.MID, &user.Status, &user.CTime, &user.MTime); err != nil {
err = errors.WithStack(err)
return
}
users = append(users, user)
}
if err = rows.Err(); err != nil {
err = errors.WithStack(err)
}
return
}
// TxUpdateUser .
func (d *Dao) TxUpdateUser(c context.Context, tx *xsql.Tx, mid int64, status model.BlockStatus) (err error) {
if _, err = tx.Exec(_upsertUser, mid, status, status); err != nil {
err = errors.WithStack(err)
return
}
return
}
// UserDetails .
func (d *Dao) UserDetails(c context.Context, mids []int64) (users []*model.DBUserDetail, err error) {
if len(mids) == 0 {
return
}
var (
sql = fmt.Sprintf(_userDetails, strings.Join(intsToStrs(mids), ","))
rows *xsql.Rows
)
if rows, err = d.db.Query(c, sql); err != nil {
err = errors.WithStack(err)
return
}
defer rows.Close()
for rows.Next() {
user := &model.DBUserDetail{}
if err = rows.Scan(&user.ID, &user.MID, &user.BlockCount, &user.CTime, &user.MTime); err != nil {
err = errors.WithStack(err)
return
}
users = append(users, user)
}
if err = rows.Err(); err != nil {
err = errors.WithStack(err)
}
return
}
// UpdateAddBlockCount .
func (d *Dao) UpdateAddBlockCount(c context.Context, mid int64) (err error) {
if _, err = d.db.Exec(c, _addAddBlockCount, mid); err != nil {
err = errors.WithStack(err)
return
}
return
}
// History 获得mid历史封禁记录
func (d *Dao) History(c context.Context, mid int64, start, limit int, desc bool) (history []*model.DBHistory, err error) {
var (
rows *xsql.Rows
)
order := "ASC"
if desc {
order = "DESC"
}
sql := fmt.Sprintf(_history, historyIdx(mid), order)
if rows, err = d.db.Query(c, sql, mid, start, limit); err != nil {
err = errors.WithStack(err)
return
}
defer rows.Close()
for rows.Next() {
h := &model.DBHistory{}
if err = rows.Scan(&h.ID, &h.MID, &h.AdminID, &h.AdminName, &h.Source, &h.Area, &h.Reason, &h.Comment, &h.Action, &h.StartTime, &h.Duration, &h.Notify, &h.CTime, &h.MTime); err != nil {
err = errors.WithStack(err)
return
}
history = append(history, h)
}
if err = rows.Err(); err != nil {
return
}
return
}
// HistoryCount 获得历史记录总长度
func (d *Dao) HistoryCount(c context.Context, mid int64) (total int, err error) {
var (
row *xsql.Row
sql = fmt.Sprintf(_historyCount, historyIdx(mid))
)
row = d.db.QueryRow(c, sql, mid)
if err = row.Scan(&total); err != nil {
err = errors.WithStack(err)
return
}
return
}
// TxInsertHistory .
func (d *Dao) TxInsertHistory(c context.Context, tx *xsql.Tx, h *model.DBHistory) (err error) {
var (
sql = fmt.Sprintf(_insertHistory, historyIdx(h.MID))
)
if _, err = tx.Exec(sql, h.MID, h.AdminID, h.AdminName, h.Source, h.Area, h.Reason, h.Comment, h.Action, h.StartTime, h.Duration, h.Notify); err != nil {
err = errors.WithStack(err)
return
}
return
}
func intsToStrs(ints []int64) (strs []string) {
for _, i := range ints {
strs = append(strs, fmt.Sprintf("%d", i))
}
return
}

View File

@@ -0,0 +1,174 @@
package block
import (
"context"
model "go-common/app/admin/main/member/model/block"
"testing"
"github.com/smartystreets/goconvey/convey"
)
func TestBlockhistoryIdx(t *testing.T) {
convey.Convey("historyIdx", t, func(ctx convey.C) {
var (
mid = int64(46333)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
p1 := historyIdx(mid)
ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
ctx.So(p1, convey.ShouldNotBeNil)
})
})
})
}
func TestBlockUser(t *testing.T) {
convey.Convey("User", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(46333)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
user, err := d.User(c, mid)
ctx.Convey("Then err should be nil.user should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
ctx.So(user, convey.ShouldNotBeNil)
})
})
})
}
func TestBlockUsers(t *testing.T) {
convey.Convey("Users", t, func(ctx convey.C) {
var (
c = context.Background()
mids = []int64{46333}
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
users, err := d.Users(c, mids)
ctx.Convey("Then err should be nil.users should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
ctx.So(users, convey.ShouldNotBeNil)
})
})
})
}
func TestBlockTxUpdateUser(t *testing.T) {
convey.Convey("TxUpdateUser", t, func(ctx convey.C) {
var (
c = context.Background()
tx, _ = d.BeginTX(c)
mid = int64(46333)
status model.BlockStatus = model.BlockStatusFalse
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
err := d.TxUpdateUser(c, tx, mid, status)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
})
})
ctx.Reset(func() {
tx.Commit()
})
})
}
func TestBlockUserDetails(t *testing.T) {
convey.Convey("UserDetails", t, func(ctx convey.C) {
var (
c = context.Background()
mids = []int64{46333}
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
users, err := d.UserDetails(c, mids)
ctx.Convey("Then err should be nil.users should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
ctx.So(users, convey.ShouldNotBeNil)
})
})
})
}
func TestBlockUpdateAddBlockCount(t *testing.T) {
convey.Convey("UpdateAddBlockCount", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(46333)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
err := d.UpdateAddBlockCount(c, mid)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
})
})
})
}
func TestBlockHistory(t *testing.T) {
convey.Convey("History", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(46333)
start = int(0)
limit = int(10)
desc bool
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
history, err := d.History(c, mid, start, limit, desc)
ctx.Convey("Then err should be nil.history should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
ctx.So(history, convey.ShouldNotBeNil)
})
})
})
}
func TestBlockHistoryCount(t *testing.T) {
convey.Convey("HistoryCount", t, func(ctx convey.C) {
var (
c = context.Background()
mid = int64(46333)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
total, err := d.HistoryCount(c, mid)
ctx.Convey("Then err should be nil.total should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
ctx.So(total, convey.ShouldNotBeNil)
})
})
})
}
func TestBlockTxInsertHistory(t *testing.T) {
convey.Convey("TxInsertHistory", t, func(ctx convey.C) {
var (
c = context.Background()
tx, _ = d.BeginTX(c)
h = &model.DBHistory{}
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
err := d.TxInsertHistory(c, tx, h)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
})
})
ctx.Reset(func() {
tx.Commit()
})
})
}
func TestBlockintsToStrs(t *testing.T) {
convey.Convey("intsToStrs", t, func(ctx convey.C) {
var (
ints = []int64{46333}
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
strs := intsToStrs(ints)
ctx.Convey("Then strs should not be nil.", func(ctx convey.C) {
ctx.So(strs, convey.ShouldNotBeNil)
})
})
})
}