go-common/app/admin/main/reply/service/service_test.go

38 lines
586 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package service
import (
"flag"
"os"
"testing"
"time"
"go-common/app/admin/main/reply/conf"
"go-common/library/log"
_ "github.com/go-sql-driver/mysql"
)
var svr *Service
func TestMain(m *testing.M) {
flag.Parse()
conf.ConfPath = "../cmd/reply-admin-test.toml"
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
svr = New(conf.Conf)
time.Sleep(time.Millisecond * 300)
m.Run()
//flush db and log
time.Sleep(time.Millisecond * 300)
os.Exit(0)
}
func WithService(f func(s *Service)) func() {
return func() {
f(svr)
}
}