update test case
This commit is contained in:
parent
6a4b9d5323
commit
28b8f91969
@ -28,6 +28,8 @@ func TestDb(t *testing.T) {
|
||||
return nil
|
||||
}()
|
||||
assert.NotEqual(t, nil, err)
|
||||
sdb := db.ToSQLDB()
|
||||
db = SQLDB2DB(sdb)
|
||||
}
|
||||
|
||||
func TestDbAlone(t *testing.T) {
|
||||
|
||||
@ -79,11 +79,16 @@ func TestGin(t *testing.T) {
|
||||
assert.Equal(t, "{\"code\":500,\"message\":\"err1\"}", getResultString("/api/error", strings.NewReader("{}")))
|
||||
}
|
||||
|
||||
// func TestResty(t *testing.T) {
|
||||
// resp, err := RestyClient.R().Get("http://taobao.com")
|
||||
// assert.Equal(t, nil, err)
|
||||
// err2 := CatchP(func() {
|
||||
// CheckRestySuccess(resp, err)
|
||||
// })
|
||||
// assert.NotEqual(t, nil, err2)
|
||||
// }
|
||||
func TestSome(t *testing.T) {
|
||||
n := MustAtoi("123")
|
||||
assert.Equal(t, 123, n)
|
||||
|
||||
wd := MustGetwd()
|
||||
assert.NotEqual(t, "", wd)
|
||||
|
||||
dir1 := GetCurrentCodeDir()
|
||||
assert.Equal(t, true, strings.HasSuffix(dir1, "common"))
|
||||
|
||||
func1 := GetFuncName()
|
||||
assert.Equal(t, true, strings.HasSuffix(func1, "TestSome"))
|
||||
}
|
||||
|
||||
@ -9,16 +9,6 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// CronPrepared cron expired prepared trans forever
|
||||
func CronPrepared() {
|
||||
for {
|
||||
notEmpty := CronTransOnce(time.Duration(0), "prepared")
|
||||
if !notEmpty {
|
||||
sleepCronTime()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CronTransOnce cron expired trans who's status match param status for once. use expireIn as expire time
|
||||
func CronTransOnce(expireIn time.Duration, status string) bool {
|
||||
defer handlePanic()
|
||||
@ -31,10 +21,10 @@ func CronTransOnce(expireIn time.Duration, status string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CronSubmitted cron expired submitted trans forever
|
||||
func CronSubmitted() {
|
||||
for {
|
||||
notEmpty := CronTransOnce(time.Duration(0), "submitted")
|
||||
// CronExpiredTrans cron expired trans, num == -1 indicate for ever
|
||||
func CronExpiredTrans(status string, num int) {
|
||||
for i := 0; i < num || num == -1; i++ {
|
||||
notEmpty := CronTransOnce(time.Duration(0), status)
|
||||
if !notEmpty {
|
||||
sleepCronTime()
|
||||
}
|
||||
|
||||
@ -16,13 +16,12 @@ import (
|
||||
var DtmServer = examples.DtmServer
|
||||
var Busi = examples.Busi
|
||||
|
||||
var myinit int = func() int {
|
||||
func init() {
|
||||
common.InitApp(common.GetProjectDir(), &config)
|
||||
config.Mysql["database"] = dbName
|
||||
PopulateMysql()
|
||||
examples.PopulateMysql()
|
||||
return 0
|
||||
}()
|
||||
}
|
||||
|
||||
func TestDtmSvr(t *testing.T) {
|
||||
TransProcessedTestChan = make(chan string, 1)
|
||||
@ -72,6 +71,8 @@ func TestCover(t *testing.T) {
|
||||
CronTransOnce(0, "submitted")
|
||||
defer handlePanic()
|
||||
checkAffected(db.DB)
|
||||
|
||||
go CronExpiredTrans("submitted", 1)
|
||||
}
|
||||
|
||||
func getTransStatus(gid string) string {
|
||||
|
||||
@ -14,8 +14,8 @@ var dtmsvrPort = 8080
|
||||
// MainStart main
|
||||
func MainStart() {
|
||||
StartSvr()
|
||||
go CronSubmitted()
|
||||
go CronPrepared()
|
||||
go CronExpiredTrans("submitted", -1)
|
||||
go CronExpiredTrans("prepared", -1)
|
||||
}
|
||||
|
||||
// StartSvr StartSvr
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user