增加生成文档的测试用例

This commit is contained in:
刘祥超
2023-01-13 19:36:10 +08:00
parent c024049778
commit ce72dcf4dc
2 changed files with 37 additions and 6 deletions

View File

@@ -0,0 +1,26 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package firewallconfigs_test
import (
"fmt"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
"strings"
"testing"
)
func TestRuleCheckpoint_Markdown(t *testing.T) {
var result = []string{}
for _, def := range firewallconfigs.AllCheckpoints {
def.Description = strings.ReplaceAll(def.Description, "<code-label>", "`")
def.Description = strings.ReplaceAll(def.Description, "</code-label>", "`")
var row = "## " + def.Name + "\n"
row += "* 名称:" + def.Name + "\n"
row += "* 代号:`${" + def.Prefix + "}`\n"
row += "* 描述:" + def.Description + "\n"
result = append(result, row)
}
fmt.Print(strings.Join(result, "\n") + "\n")
}

View File

@@ -1,17 +1,22 @@
package firewallconfigs
package firewallconfigs_test
import (
"fmt"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
"strings"
"testing"
)
func TestRuleOperator_Markdown(t *testing.T) {
result := []string{}
for _, def := range AllRuleOperators {
row := "## " + def.Name + "\n"
row += "符号:`" + def.Code + "`\n"
row += "描述:" + def.Description + "\n"
var result = []string{}
for _, def := range firewallconfigs.AllRuleOperators {
def.Description = strings.ReplaceAll(def.Description, "<code-label>", "`")
def.Description = strings.ReplaceAll(def.Description, "</code-label>", "`")
var row = "## " + def.Name + "\n"
row += "* 名称:" + def.Name + "\n"
row += "* 代号:`" + def.Code + "`\n"
row += "* 描述:" + def.Description + "\n"
result = append(result, row)
}