diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 786376d5..a26681bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,7 @@ jobs: with: file: ./coverage.txt flags: unittests + token: ${{ secrets.CODECOV_TOKEN }} lint: runs-on: ubuntu-latest diff --git a/config/json/deploy.go b/config/json/deploy.go index 16810e2b..e96847b3 100644 --- a/config/json/deploy.go +++ b/config/json/deploy.go @@ -100,20 +100,9 @@ func transformDeploymentsToJSON(configDeployments config.Deployments) jsonDeploy simple: c.Name, }) } else { - args := make([]map[string]any, 0) + args := make([]any, 0) for _, arg := range c.Args { - jsonEncoded, err := jsoncdc.Encode(arg) - if err != nil { - panic(err) - } - - jsonMap := make(map[string]any) - err = json.Unmarshal(jsonEncoded, &jsonMap) - if err != nil { - panic(err) - } - - args = append(args, jsonMap) + args = append(args, jsoncdc.Prepare(arg)) } deployments = append(deployments, deployment{ @@ -139,8 +128,8 @@ func transformDeploymentsToJSON(configDeployments config.Deployments) jsonDeploy } type contractDeployment struct { - Name string `json:"name"` - Args []map[string]any `json:"args"` + Name string `json:"name"` + Args []any `json:"args"` } type deployment struct { diff --git a/config/json/deploy_test.go b/config/json/deploy_test.go index 95eb3988..236ea1d6 100644 --- a/config/json/deploy_test.go +++ b/config/json/deploy_test.go @@ -103,17 +103,23 @@ func Test_TransformDeployToJSON(t *testing.T) { } }`) - var jsonDeployments jsonDeployments - err := json.Unmarshal(b, &jsonDeployments) + var original jsonDeployments + err := json.Unmarshal(b, &original) assert.NoError(t, err) - deployments, err := jsonDeployments.transformToConfig() + deployments, err := original.transformToConfig() assert.NoError(t, err) j := transformDeploymentsToJSON(deployments) x, _ := json.Marshal(j) - assert.Equal(t, cleanSpecialChars(b), cleanSpecialChars(x)) + // Unmarshal the config again to compare against the original + var result jsonDeployments + err = json.Unmarshal(x, &result) + assert.NoError(t, err) + + // Check that result is same as original after transformation + assert.Equal(t, original, result) } func Test_DeploymentAdvanced(t *testing.T) { diff --git a/schema.json b/schema.json index 4b23dfe9..48d412c1 100644 --- a/schema.json +++ b/schema.json @@ -120,9 +120,7 @@ "type": "string" }, "args": { - "items": { - "type": "object" - }, + "items": true, "type": "array" } },