blog_backend_api/test/portData_test.go

52 lines
936 B
Go
Raw Normal View History

package test
import (
"background/config"
"background/db"
"background/logs"
"background/model"
"log"
"testing"
)
func InitConfig() {
e := config.Init("user.yaml")
if nil != e {
log.Println(e.Error())
}
}
func InitMysql() {
c := config.GetMysqlConfig()
if c == nil {
logs.Error("cannnot connect mysql server")
} else {
db.Init()
}
}
func InitRedisConfig() {
e := config.InitRedis()
if nil != e {
logs.Error(e.Error())
return
}
}
func InitElasticSearch(){
e := db.GetElastic().CreateIndex("hardware",model.HardwareTypeMapping())
if nil != e{
}
}
func InitLogs() {
logs.Init(config.GetLogConfig().Dir, config.GetLogConfig().File, config.GetLogConfig().Level, config.GetLogConfig().SaveFile)
}
func TestPortDocToElastic(t *testing.T) {
InitConfig()
InitLogs()
InitRedisConfig()
InitMysql()
InitElasticSearch()
db.InitELK()
e := model.PortDocumentToElasticsearch("doc")
if nil != e{
t.Error(e)
}
}