提交 6ea687af 编写于 作者: martianzhang's avatar martianzhang

update TestTranslation golden file

上级 06caff88
......@@ -18,10 +18,10 @@ package advisor
import (
"flag"
"sort"
"testing"
"github.com/XiaoMi/soar/common"
"github.com/kr/pretty"
)
......@@ -56,15 +56,25 @@ func TestIsIgnoreRule(t *testing.T) {
}
func TestTranslation(t *testing.T) {
languages := []string{"english"}
languages := []string{"english", "", "cn", "en", "chinese"}
testRules := make(map[string]Rule)
for item, rule := range HeuristicRules {
testRules[item] = rule
if item != "OK" {
testRules[item] = rule
}
}
err := common.GoldenDiff(func() {
for _, language := range languages {
common.Log.Debug("TestTranslation %s", language)
pretty.Println(Translation(language, testRules))
suggests := Translation(language, testRules)
var sortedSuggest []string
for item := range suggests {
sortedSuggest = append(sortedSuggest, item)
}
sort.Strings(sortedSuggest)
for _, item := range sortedSuggest {
pretty.Println(suggests[item])
}
}
}, t.Name(), update)
if nil != err {
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -67,9 +67,6 @@ func captureOutput(f func()) string {
r, w, _ := os.Pipe()
os.Stdout = w
// execute function
f()
outC := make(chan string)
// copy the output in a separate goroutine so printing can't block indefinitely
go func() {
......@@ -81,6 +78,9 @@ func captureOutput(f func()) string {
outC <- buf.String()
}()
// execute function
f()
// back to normal state
err := w.Close()
if err != nil {
......
......@@ -17,4 +17,4 @@ allow-online-as-test: true
log-level: 7
log-output: soar.log
sampling: true
sampling: false
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册