|
|
@ -9,6 +9,8 @@ import ( |
|
|
|
"github.com/stretchr/testify/assert" |
|
|
|
) |
|
|
|
|
|
|
|
// pipeline deserialization
|
|
|
|
|
|
|
|
func TestImagePipelineDeserialization(t *testing.T) { |
|
|
|
const Payload string = `{ |
|
|
|
"name": "example pipeline", |
|
|
@ -61,6 +63,8 @@ func TestVideoPipelineDeserialization(t *testing.T) { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// image pipeline steps
|
|
|
|
|
|
|
|
func TestResizeImage(t *testing.T) { |
|
|
|
const Payload string = `{ |
|
|
|
"name": "example pipeline", |
|
|
@ -100,6 +104,45 @@ func TestResizeImage(t *testing.T) { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func TestRotateImage(t *testing.T) { |
|
|
|
const Payload string = `{ |
|
|
|
"name": "example pipeline", |
|
|
|
"type": 1, |
|
|
|
"removeMetadata": false, |
|
|
|
"steps": [ |
|
|
|
{ |
|
|
|
"name": "rotate image", |
|
|
|
"type": 1, |
|
|
|
"options": { |
|
|
|
"angle": 90.0 |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
}` |
|
|
|
const Bucket string = "pipeline_test_03" |
|
|
|
|
|
|
|
t.Run("Image rotating is successful", func(t *testing.T) { |
|
|
|
wd, _ := os.Getwd() |
|
|
|
pipe := DeserializePipelines([][]byte{[]byte(Payload)})[0] |
|
|
|
|
|
|
|
storageProvider := storage.GetFileSystemStorageProvider("test", "..") |
|
|
|
|
|
|
|
_, 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")) |
|
|
|
|
|
|
|
dest, err := pipe.Run("source.jpg", Bucket, storageProvider) |
|
|
|
assert.Nil(t, err) |
|
|
|
assert.FileExists(t, storageProvider.GetPath(Bucket, dest)) |
|
|
|
|
|
|
|
// clean up
|
|
|
|
os.Remove(storageProvider.GetPath(Bucket, "source.jpg")) |
|
|
|
os.Remove(storageProvider.GetPath(Bucket, dest)) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// output options
|
|
|
|
|
|
|
|
func TestEncodeImageWithJpegQuality(t *testing.T) { |
|
|
|
const Payload string = `{ |
|
|
|
"name": "example pipeline", |
|
|
@ -122,7 +165,7 @@ func TestEncodeImageWithJpegQuality(t *testing.T) { |
|
|
|
}` |
|
|
|
const Bucket string = "pipeline_test_02" |
|
|
|
|
|
|
|
t.Run("Image resizing is successful", func(t *testing.T) { |
|
|
|
t.Run("Image encoding with jpeg quality is successful", func(t *testing.T) { |
|
|
|
wd, _ := os.Getwd() |
|
|
|
pipe := DeserializePipelines([][]byte{[]byte(Payload)})[0] |
|
|
|
|
|
|
|