forked from FabianVowie/Lithium
Browse Source
Merge commit 'dbcf08b197b6b08352597588611e489f8188f643' into HEAD
feature/add-storage-layer
Merge commit 'dbcf08b197b6b08352597588611e489f8188f643' into HEAD
feature/add-storage-layer
Jenkins
3 years ago
7 changed files with 139 additions and 24 deletions
-
14config/example.json
-
15main.go
-
8pipelines/executable_step.go
-
80pipelines/executable_step_test.go
-
2pipelines/pipeline.go
-
32pipelines/step.go
-
12pipelines/step_test.go
@ -0,0 +1,80 @@ |
|||
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].GetExecutable() |
|||
|
|||
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].GetExecutable() |
|||
|
|||
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].GetExecutable() |
|||
|
|||
assert.EqualError(t, err, "unexpected end of JSON input") |
|||
}) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue