Skip to content

Commit

Permalink
Fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DamjanBecirovic committed Jun 10, 2021
1 parent c3a74c6 commit b02d52f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
10 changes: 6 additions & 4 deletions pkg/parameters/expression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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

Expand Down
22 changes: 11 additions & 11 deletions pkg/pipelines/parameters_evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 11 additions & 11 deletions test/e2e/parameters_and_change_in.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,38 +113,38 @@
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
blocks:
- name: Build and push image
skip:
when: "branch = 'master' and true"
when: "(branch = 'master') and true"
task:
secrets:
- name: prod_dockerhub
Expand All @@ -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
Expand All @@ -173,5 +173,5 @@
promotions:
- name: Performance tests
auto_promote:
when: "branch = 'master' and true"
when: "(branch = 'master') and true"
}))

0 comments on commit b02d52f

Please sign in to comment.