|
@@ -2,6 +2,8 @@ package approve_former
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
+ "git.sxidc.com/go-tools/argo-api"
|
|
|
+ "git.sxidc.com/go-tools/argo-api/client"
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
"io"
|
|
|
"os"
|
|
@@ -12,7 +14,7 @@ import (
|
|
|
func TestParseFlowFromJson(t *testing.T) {
|
|
|
// 测试结构解析
|
|
|
frontJson := readJsonFile("./front_json/full.json")
|
|
|
- argoTmp, err := ParseFlowFromJson("full", "测试流程", frontJson, "")
|
|
|
+ argoTmp, err := ParseFlowFromJson("1", "测试流程", "duyong", frontJson, "")
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
@@ -21,19 +23,38 @@ func TestParseFlowFromJson(t *testing.T) {
|
|
|
|
|
|
func TestParseEmptyFlowFromJson(t *testing.T) {
|
|
|
frontJson := readJsonFile("./front_json/empty.json")
|
|
|
- _, err := ParseFlowFromJson("empty", "测试流程", frontJson, "")
|
|
|
+ _, err := ParseFlowFromJson("2", "测试流程", "duyong", frontJson, "")
|
|
|
assert.ErrorIs(t, err, ErrNodeEmpty)
|
|
|
}
|
|
|
|
|
|
func TestParseSingleFlowFromJsonFile(t *testing.T) {
|
|
|
frontJson := readJsonFile("./front_json/approval_one_user.json")
|
|
|
- argoTmp, err := ParseFlowFromJson("single", "测试流程", frontJson, "")
|
|
|
+ argObj := `{"props":{"labelWidth":100,"labelPosition":"top","size":"large"},"formItems":[],"span":12}`
|
|
|
+ argoTmp, err := ParseFlowFromJson("3", "single", "duyong", frontJson, argObj)
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
fmt.Println(argoTmp)
|
|
|
}
|
|
|
|
|
|
+func TestGetParsedWorkfolw(t *testing.T) {
|
|
|
+ err := argo.Init("/Users/duyong/WorkPlace/fangshi/meta-business/argo/test/k3s.yaml")
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("%+v\n", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ defer argo.Destroy()
|
|
|
+
|
|
|
+ wfs, err := argo.GetInstance().GetWorkflowsInNamespace(client.GetWorkflowsInNamespaceParams{
|
|
|
+ Namespace: "default",
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("%+v\n", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Println(wfs)
|
|
|
+}
|
|
|
+
|
|
|
func readJsonFile(filePath string) string {
|
|
|
file, err := os.Open(filePath)
|
|
|
if err != nil {
|