background/test/portData_test.go

54 lines
941 B
Go
Raw Normal View History

package test
import (
"background/config"
"background/db"
"background/logs"
"background/model"
"log"
"testing"
)
2020-11-10 16:05:17 +00:00
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
}
}
2020-11-10 16:05:17 +00:00
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)
}
2020-11-10 16:05:17 +00:00
func TestPortDocToElastic(t *testing.T) {
InitConfig()
InitLogs()
InitRedisConfig()
InitMysql()
InitElasticSearch()
db.InitELK()
e := model.PortDocumentToElasticsearch("doc")
2020-11-10 16:05:17 +00:00
if nil != e {
t.Error(e)
}
2020-11-10 16:05:17 +00:00
}