Roman Zipp
3 years ago
6 changed files with 96 additions and 19 deletions
-
14config/example.json
-
8pipelines/executable_step.go
-
55pipelines/executable_step_test.go
-
2pipelines/pipeline.go
-
28pipelines/step.go
-
8pipelines/step_test.go
@ -0,0 +1,55 @@ |
|||
package pipelines |
|||
|
|||
import ( |
|||
"github.com/stretchr/testify/assert" |
|||
"testing" |
|||
) |
|||
|
|||
func TestDeserializeOptions(t *testing.T) { |
|||
const Payload string = `{ |
|||
"name": "example pipeline", |
|||
"type": 0, |
|||
"removeMetadata": false, |
|||
"steps": [ |
|||
{ |
|||
"name": "resize image", |
|||
"type": 0, |
|||
"options": { |
|||
"width": 1280, |
|||
"height": 720, |
|||
"upscale": false |
|||
} |
|||
} |
|||
] |
|||
}` |
|||
|
|||
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", |
|||
"type": 0, |
|||
"removeMetadata": false, |
|||
"steps": [ |
|||
{ |
|||
"name": "resize image", |
|||
"type": 0 |
|||
} |
|||
] |
|||
}` |
|||
|
|||
t.Run("Image pipeline deserialization is successful", func(t *testing.T) { |
|||
values := DeserializePipelines([][]byte{[]byte(Payload)}) |
|||
|
|||
_, err := values[0].GetSteps()[0].Translate() |
|||
|
|||
assert.EqualError(t, err, "unexpected end of JSON input") |
|||
}) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue