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, nil) if err != nil { t.Fatal(err) } fmt.Println(argoTmp) } func TestParseEmptyFlowFromJson(t *testing.T) { frontJson := readJsonFile("./front_json/empty.json") _, err := ParseFlowFromJson("empty", frontJson, nil) assert.ErrorIs(t, err, ErrNodeEmpty) } 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) }