Skip to content

Commit

Permalink
Merge pull request #3 from saymedia/ADS-5069-Make-wait-step-exception
Browse files Browse the repository at this point in the history
Added wait step check
  • Loading branch information
HojunByun authored Feb 10, 2022
2 parents 26afe69 + 596ee15 commit b5e6816
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ func lowerStep(step Step, context *Context, stepContext *StepContext) Step {
env, ok := step["env"].(map[interface{}]interface{})
if !ok {
env = make(map[interface{}]interface{})
step["env"] = env
if _, exists := step["wait"]; !exists {
step["env"] = env
}
}
env["JOBSWORTH_CAUTIOUS"] = stepContext.CautiousStr()
env["JOBSWORTH_CODEBASE"] = context.CodebaseName()
Expand Down
26 changes: 26 additions & 0 deletions pipeline_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"reflect"
"testing"

"gopkg.in/yaml.v2"
Expand All @@ -26,3 +27,28 @@ plugins:
}
deepCopyStep(step)
}

func TestWaitStep(t *testing.T) {
context := &Context{}
stepContext := &StepContext{}

step := Step{}
stepBytes := []byte(`
command: foo
`)
yaml.Unmarshal(stepBytes, &step)
step = lowerStep(step, context, stepContext)
if reflect.DeepEqual(step["env"], nil) {
t.Errorf("env should be set")
}

step = Step{}
stepBytes = []byte(`
wait: ~
`)
yaml.Unmarshal(stepBytes, &step)
step = lowerStep(step, context, stepContext)
if !reflect.DeepEqual(step["env"], nil) {
t.Errorf("env should not be set for a wait step")
}
}

0 comments on commit b5e6816

Please sign in to comment.