mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-04 05:00:24 +08:00
增加生成文档的测试用例
This commit is contained in:
@@ -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")
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user