|
|
@@ -1,6 +1,11 @@
|
|
|
package test
|
|
|
|
|
|
-import _ "embed"
|
|
|
+import (
|
|
|
+ _ "embed"
|
|
|
+ "github.com/pkg/errors"
|
|
|
+ "sort"
|
|
|
+ "testing"
|
|
|
+)
|
|
|
|
|
|
const (
|
|
|
baseUrl = "https://localhost:32337"
|
|
|
@@ -11,3 +16,43 @@ const (
|
|
|
|
|
|
//go:embed approve_workflow_template.yaml
|
|
|
var templateYamlStr []byte
|
|
|
+
|
|
|
+//go:embed approve_workflow.yaml
|
|
|
+var workflowYamlStr []byte
|
|
|
+
|
|
|
+func compareDefinitionMap(t *testing.T, definitionMap map[string]any, checkDefinitionMaps map[string]any) {
|
|
|
+ keys := make([]string, 0)
|
|
|
+ for key, _ := range definitionMap {
|
|
|
+ keys = append(keys, key)
|
|
|
+ }
|
|
|
+
|
|
|
+ sort.Strings(keys)
|
|
|
+
|
|
|
+ for _, key := range keys {
|
|
|
+ innerDefinitionMap, ok := definitionMap[key].(map[string]any)
|
|
|
+ if ok {
|
|
|
+ compareDefinitionMap(t, innerDefinitionMap, checkDefinitionMaps[key].(map[string]any))
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ sliceValues, ok := definitionMap[key].([]any)
|
|
|
+ if ok {
|
|
|
+ for i, sliceValue := range sliceValues {
|
|
|
+ innerDefinitionMap, ok := sliceValue.(map[string]any)
|
|
|
+ if ok {
|
|
|
+ compareDefinitionMap(t, innerDefinitionMap, checkDefinitionMaps[key].([]any)[i].(map[string]any))
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if sliceValue != checkDefinitionMaps[key].([]any)[i] {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("key: %v value %v", key, definitionMap[key]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if definitionMap[key] != checkDefinitionMaps[key] {
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("key: %v value %v", key, definitionMap[key]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|