forked from FabianVowie/Lithium
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.5 KiB
80 lines
1.5 KiB
package pipelines
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestDeserializeOptionsResizeImage(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 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",
|
|
"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")
|
|
})
|
|
}
|