123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package approve_former
- import (
- "fmt"
- "github.com/stretchr/testify/assert"
- "io"
- "os"
- "testing"
- )
- // TestParseFlowFromJson 测试整体结构解析
- func TestParseFlowFromJson(t *testing.T) {
- // 测试结构解析
- frontJson := readJsonFile("./front_json/full.json")
- argoTmp, err := ParseFlowFromJson("full", "测试流程", frontJson, "")
- if err != nil {
- t.Fatal(err)
- }
- fmt.Println(argoTmp)
- }
- func TestParseEmptyFlowFromJson(t *testing.T) {
- frontJson := readJsonFile("./front_json/empty.json")
- _, err := ParseFlowFromJson("empty", "测试流程", frontJson, "")
- assert.ErrorIs(t, err, ErrNodeEmpty)
- }
- func TestParseSingleFlowFromJsonFile(t *testing.T) {
- frontJson := readJsonFile("./front_json/approval_one_user.json")
- argoTmp, err := ParseFlowFromJson("single", "测试流程", frontJson, "")
- if err != nil {
- t.Fatal(err)
- }
- fmt.Println(argoTmp)
- }
- func readJsonFile(filePath string) string {
- file, err := os.Open(filePath)
- if err != nil {
- panic(err)
- }
- defer file.Close()
- content, err := io.ReadAll(file)
- if err != nil {
- panic(err)
- }
- return string(content)
- }
|