Browse Source

Rename step executable getter method

feature/add-executable-steps
Roman Zipp 3 years ago
parent
commit
d863b7211e
  1. 6
      pipelines/executable_step_test.go
  2. 2
      pipelines/step.go
  3. 4
      pipelines/step_test.go

6
pipelines/executable_step_test.go

@ -26,7 +26,7 @@ func TestDeserializeOptionsResizeImage(t *testing.T) {
t.Run("Image pipeline deserialization is successful", func(t *testing.T) {
values := DeserializePipelines([][]byte{[]byte(Payload)})
_, err := values[0].GetSteps()[0].Translate()
_, err := values[0].GetSteps()[0].GetExecutable()
assert.Equal(t, nil, err)
})
@ -51,7 +51,7 @@ func TestDeserializeOptionsCompressImage(t *testing.T) {
t.Run("Image pipeline deserialization is successful", func(t *testing.T) {
values := DeserializePipelines([][]byte{[]byte(Payload)})
_, err := values[0].GetSteps()[0].Translate()
_, err := values[0].GetSteps()[0].GetExecutable()
assert.Equal(t, nil, err)
})
@ -73,7 +73,7 @@ func TestDeserializeMissingOptions(t *testing.T) {
t.Run("Image pipeline deserialization is successful", func(t *testing.T) {
values := DeserializePipelines([][]byte{[]byte(Payload)})
_, err := values[0].GetSteps()[0].Translate()
_, err := values[0].GetSteps()[0].GetExecutable()
assert.EqualError(t, err, "unexpected end of JSON input")
})

2
pipelines/step.go

@ -18,7 +18,7 @@ type Step struct {
Options json.RawMessage `json:"options"`
}
func (s Step) Translate() (IExecutableStep, error) {
func (s Step) GetExecutable() (IExecutableStep, error) {
switch s.GetType() {
case TypeResizeImageStep:
step := ResizeImageStep{}

4
pipelines/step_test.go

@ -28,7 +28,7 @@ func TestTranslateStep(t *testing.T) {
assert.Equal(t, "resize image", steps[0].GetName())
assert.Equal(t, TypeResizeImageStep, steps[0].GetType())
translated, err := steps[0].Translate()
translated, err := steps[0].GetExecutable()
assert.Equal(t, nil, err)
assert.IsType(t, ResizeImageStep{}, translated)
})
@ -57,7 +57,7 @@ func TestInvalidStepType(t *testing.T) {
assert.Equal(t, "resize image", steps[0].GetName())
assert.Equal(t, StepType(99999), steps[0].GetType())
translated, err := steps[0].Translate()
translated, err := steps[0].GetExecutable()
assert.EqualError(t, err, "invalid type")
assert.Nil(t, translated)
})

Loading…
Cancel
Save