|
|
@ -362,4 +362,44 @@ func TestEncoding(t *testing.T) { |
|
|
|
os.Remove(storageProvider.GetPath(Bucket, "source.jpg")) |
|
|
|
os.Remove(storageProvider.GetPath(Bucket, dest)) |
|
|
|
}) |
|
|
|
|
|
|
|
t.Run("Wrong output format results in error", func(t *testing.T) { |
|
|
|
const InvalidPayload string = `{ |
|
|
|
"name": "example pipeline", |
|
|
|
"type": 1, |
|
|
|
"removeMetadata": false, |
|
|
|
"steps": [ |
|
|
|
{ |
|
|
|
"name": "resize image", |
|
|
|
"type": 0, |
|
|
|
"options": { |
|
|
|
"width": 1280, |
|
|
|
"height": 720, |
|
|
|
"upscale": false |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
"output": { |
|
|
|
"format": "foo", |
|
|
|
"quality": 50 |
|
|
|
} |
|
|
|
}` |
|
|
|
|
|
|
|
wd, _ := os.Getwd() |
|
|
|
pipe := DeserializePipelines([][]byte{[]byte(InvalidPayload)})[0] |
|
|
|
|
|
|
|
storageProvider := storage.GetFileSystemStorageProvider("test", "..") |
|
|
|
|
|
|
|
// copy test file to storage bucket
|
|
|
|
_, err := storageProvider.StoreExisting(Bucket, "source.jpg", filepath.Join(wd, "../tests/files/900x900.jpg")) |
|
|
|
assert.Nil(t, err, "Test file should be readable") |
|
|
|
assert.FileExists(t, storageProvider.GetPath(Bucket, "source.jpg")) |
|
|
|
|
|
|
|
// run pipeline steps
|
|
|
|
_, err = pipe.Run("source.jpg", Bucket, storageProvider) |
|
|
|
assert.EqualError(t, err, "output format 'foo' is not supported") |
|
|
|
|
|
|
|
// clean up
|
|
|
|
os.Remove(storageProvider.GetPath(Bucket, "source.jpg")) |
|
|
|
}) |
|
|
|
} |