From b02d52f13abe443031e1513cbd1f79a5d6900c4e Mon Sep 17 00:00:00 2001 From: Damjan Becirovic Date: Thu, 10 Jun 2021 19:19:04 +0200 Subject: [PATCH] Fix linter issues --- pkg/parameters/expression_test.go | 10 ++++++---- pkg/pipelines/parameters_evaluator_test.go | 22 +++++++++++----------- test/e2e/parameters_and_change_in.rb | 22 +++++++++++----------- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/pkg/parameters/expression_test.go b/pkg/parameters/expression_test.go index 0704d38..997ad78 100644 --- a/pkg/parameters/expression_test.go +++ b/pkg/parameters/expression_test.go @@ -7,8 +7,10 @@ import ( assert "github.com/stretchr/testify/assert" ) +const Foo string = "Foo" + func Test__Substitute(t *testing.T) { - os.Setenv("TEST_VAL_1", "Foo") + os.Setenv("TEST_VAL_1", Foo) os.Setenv("TEST_VAL_2", "Bar") os.Setenv("TEST_VAL_3", "Baz") @@ -23,17 +25,17 @@ func Test__Substitute(t *testing.T) { exp.Expression = "${{parameters.TEST_VAL_1}}" err := exp.Substitute() assert.Nil(t, err) - assert.Equal(t, "Foo", exp.Value) + assert.Equal(t, Foo, exp.Value) exp.Expression = "${{ parameters.TEST_VAL_1}}" err = exp.Substitute() assert.Nil(t, err) - assert.Equal(t, "Foo", exp.Value) + assert.Equal(t, Foo, exp.Value) exp.Expression = "${{ parameters.TEST_VAL_1 }}" err = exp.Substitute() assert.Nil(t, err) - assert.Equal(t, "Foo", exp.Value) + assert.Equal(t, Foo, exp.Value) // Text before and after params expression diff --git a/pkg/pipelines/parameters_evaluator_test.go b/pkg/pipelines/parameters_evaluator_test.go index 191eec9..d6ad076 100644 --- a/pkg/pipelines/parameters_evaluator_test.go +++ b/pkg/pipelines/parameters_evaluator_test.go @@ -87,21 +87,21 @@ func Test__Run(t *testing.T) { err = e.Run() assert.Nil(t, err) - yaml_result, er := e.pipeline.ToYAML() + yamlResult, er := e.pipeline.ToYAML() assert.Nil(t, er) - fmt.Printf("%s\n", yaml_result) + fmt.Printf("%s\n", yamlResult) - assert_value_on_path(t, e, []string{"name"}, "Deploy to prod on server_1") - assert_value_on_path(t, e, []string{"queue", "0", "name"}, "prod_deployment_queue") - assert_value_on_path(t, e, []string{"queue", "1", "name"}, "MISSING_queue") - assert_value_on_path(t, e, []string{"global_job_config", "secrets", "0", "name"}, "prod_deploy_key") - assert_value_on_path(t, e, []string{"blocks", "0", "task", "secrets", "0", "name"}, "prod_dockerhub") - assert_value_on_path(t, e, []string{"blocks", "0", "task", "secrets", "1", "name"}, "prod_ecr") - assert_value_on_path(t, e, []string{"blocks", "1", "task", "secrets", "0", "name"}, "prod_deploy_key") - assert_value_on_path(t, e, []string{"blocks", "1", "task", "secrets", "1", "name"}, "prod_aws_creds") + assertValueOnPath(t, e, []string{"name"}, "Deploy to prod on server_1") + assertValueOnPath(t, e, []string{"queue", "0", "name"}, "prod_deployment_queue") + assertValueOnPath(t, e, []string{"queue", "1", "name"}, "MISSING_queue") + assertValueOnPath(t, e, []string{"global_job_config", "secrets", "0", "name"}, "prod_deploy_key") + assertValueOnPath(t, e, []string{"blocks", "0", "task", "secrets", "0", "name"}, "prod_dockerhub") + assertValueOnPath(t, e, []string{"blocks", "0", "task", "secrets", "1", "name"}, "prod_ecr") + assertValueOnPath(t, e, []string{"blocks", "1", "task", "secrets", "0", "name"}, "prod_deploy_key") + assertValueOnPath(t, e, []string{"blocks", "1", "task", "secrets", "1", "name"}, "prod_aws_creds") } -func assert_value_on_path(t *testing.T, e *parametersEvaluator, path []string, value string) { +func assertValueOnPath(t *testing.T, e *parametersEvaluator, path []string, value string) { field, ok := e.pipeline.raw.Search(path...).Data().(string) if !ok { assert.Equal(t, "Invalid value after parsing at", path) diff --git a/test/e2e/parameters_and_change_in.rb b/test/e2e/parameters_and_change_in.rb index bb9c8de..66ad0a3 100644 --- a/test/e2e/parameters_and_change_in.rb +++ b/test/e2e/parameters_and_change_in.rb @@ -113,30 +113,30 @@ fail_fast: cancel: -when: "branch = 'master' and true" + when: "(branch = 'master') and true" stop: -when: "branch = 'master' and false" + when: "(branch = 'master') and false" auto_cancel: queued: -when: "branch = 'master' and true" + when: "(branch = 'master') and true" running: -when: "branch = 'master' and false" + when: "(branch = 'master') and false" global_job_config: priority: - value: 1 - when: "branch = 'master' and true" + when: "(branch = 'master') and true" secrets: - name: "prod_github" - name: "github_key" queue: - name: "prod_deployment_queue" - when: "branch = 'master' and true" + when: "(branch = 'master') and true" - name: "MISSING_queue" - when: "branch = 'master' and false" + when: "(branch = 'master') and false" - name: "default_queue" when: true @@ -144,7 +144,7 @@ blocks: - name: Build and push image skip: - when: "branch = 'master' and true" + when: "(branch = 'master') and true" task: secrets: - name: prod_dockerhub @@ -153,14 +153,14 @@ - name: Build & Push priority: - value: 1 - when: "branch = 'master' and true" + when: "(branch = 'master') and true" commands: - make build - make push - name: Deploy image run : - when: "branch = 'master' and false" + when: "(branch = 'master') and false" task: secrets: - name: prod_deploy_key @@ -173,5 +173,5 @@ promotions: - name: Performance tests auto_promote: - when: "branch = 'master' and true" + when: "(branch = 'master') and true" }))