From 60330602d4f3ad443f3f9dc93613631da75962eb Mon Sep 17 00:00:00 2001 From: "DESKTOP-4RNDQIC\\29019" <290198252@qq.com> Date: Wed, 11 Nov 2020 00:05:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=87=E6=A1=A3=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=AF=94=E5=AF=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 2 +- test/git_test.go | 23 +++++++++++++++++++++++ test/portData_test.go | 13 +++++++------ 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 test/git_test.go diff --git a/main.go b/main.go index 6832502..4769909 100644 --- a/main.go +++ b/main.go @@ -97,7 +97,7 @@ func main() { InitLogs() InitRedisConfig() InitMysql() - InitElasticSearch() + //InitElasticSearch() //o := db.GetMongoDb() //mgo = mgo diff --git a/test/git_test.go b/test/git_test.go new file mode 100644 index 0000000..1492b24 --- /dev/null +++ b/test/git_test.go @@ -0,0 +1,23 @@ +package test + +import ( + "log" + "testing" + + "github.com/sergi/go-diff/diffmatchpatch" +) + +const ( + text1 = "Lorem ipsum dolor." + text2 = "Lorem dolor sit amet. sdfsdfsd" +) + +func TestDiff(t *testing.T) { + dmp := diffmatchpatch.New() + + diffs := dmp.DiffMain(text1, text2, false) + log.Print(diffs) + prettydiff := dmp.DiffPrettyText(diffs) + + log.Print(prettydiff) +} diff --git a/test/portData_test.go b/test/portData_test.go index 25c075b..57ab66b 100644 --- a/test/portData_test.go +++ b/test/portData_test.go @@ -8,6 +8,7 @@ import ( "log" "testing" ) + func InitConfig() { e := config.Init("user.yaml") if nil != e { @@ -29,16 +30,16 @@ func InitRedisConfig() { return } } -func InitElasticSearch(){ - e := db.GetElastic().CreateIndex("hardware",model.HardwareTypeMapping()) - if nil != e{ +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) { +func TestPortDocToElastic(t *testing.T) { InitConfig() InitLogs() InitRedisConfig() @@ -46,7 +47,7 @@ func TestPortDocToElastic(t *testing.T) { InitElasticSearch() db.InitELK() e := model.PortDocumentToElasticsearch("doc") - if nil != e{ + if nil != e { t.Error(e) } -} \ No newline at end of file +}