diff --git a/pipelines/executable_step_test.go b/pipelines/executable_step_test.go index f7cddf9..0a4bb31 100644 --- a/pipelines/executable_step_test.go +++ b/pipelines/executable_step_test.go @@ -5,7 +5,7 @@ import ( "testing" ) -func TestDeserializeOptions(t *testing.T) { +func TestDeserializeOptionsResizeImage(t *testing.T) { const Payload string = `{ "name": "example pipeline", "type": 0, @@ -32,6 +32,31 @@ func TestDeserializeOptions(t *testing.T) { }) } +func TestDeserializeOptionsCompressImage(t *testing.T) { + const Payload string = `{ + "name": "example pipeline", + "type": 0, + "removeMetadata": false, + "steps": [ + { + "name": "compress image", + "type": 1, + "options": { + "quality": 80 + } + } + ] + }` + + t.Run("Image pipeline deserialization is successful", func(t *testing.T) { + values := DeserializePipelines([][]byte{[]byte(Payload)}) + + _, err := values[0].GetSteps()[0].Translate() + + assert.Equal(t, nil, err) + }) +} + func TestDeserializeMissingOptions(t *testing.T) { const Payload string = `{ "name": "example pipeline", diff --git a/pipelines/step.go b/pipelines/step.go index 99a95ad..eaed75c 100644 --- a/pipelines/step.go +++ b/pipelines/step.go @@ -25,10 +25,14 @@ func (s Step) Translate() (IExecutableStep, error) { if err := json.Unmarshal(s.Options, &step.Options); err != nil { return nil, err } + return step, nil + case TypeCompressImageStep: + step := CompressImageStep{} + if err := json.Unmarshal(s.Options, &step.Options); err != nil { + return nil, err + } return step, nil - //case TypeCompressImageStep: - // step = CompressImageStep{s} } return nil, errors.New("invalid type")