Browse Source

Refactor pipeline tests

Roman Zipp 3 years ago
committed by Fabian Vowie
parent
commit
337e8af0e2
No known key found for this signature in database GPG Key ID: C27317C33B27C410
  1. 30
      pipelines/pipeline_test.go

30
pipelines/pipeline_test.go

@ -12,7 +12,8 @@ import (
// pipeline deserialization // pipeline deserialization
func TestImagePipelineDeserialization(t *testing.T) {
func TestPipelineDeserialization(t *testing.T) {
t.Run("Image pipeline deserialization is successful", func(t *testing.T) {
const Payload string = `{ const Payload string = `{
"name": "example pipeline", "name": "example pipeline",
"type": 0, "type": 0,
@ -29,16 +30,14 @@ func TestImagePipelineDeserialization(t *testing.T) {
] ]
}` }`
t.Run("Image pipeline deserialization is successful", func(t *testing.T) {
values := DeserializePipelines([][]byte{[]byte(Payload)}) values := DeserializePipelines([][]byte{[]byte(Payload)})
assert.Equal(t, 1, len(values), "Output should contain one element") assert.Equal(t, 1, len(values), "Output should contain one element")
assert.Equal(t, "example pipeline", values[0].GetName()) assert.Equal(t, "example pipeline", values[0].GetName())
assert.Equal(t, Image, values[0].GetType()) assert.Equal(t, Image, values[0].GetType())
}) })
}
func TestVideoPipelineDeserialization(t *testing.T) {
t.Run("Video pipelines deserialization is successful", func(t *testing.T) {
const Payload string = `{ const Payload string = `{
"name": "example pipeline", "name": "example pipeline",
"type": 1, "type": 1,
@ -55,7 +54,6 @@ func TestVideoPipelineDeserialization(t *testing.T) {
] ]
}` }`
t.Run("Video pipelines deserialization is successful", func(t *testing.T) {
values := DeserializePipelines([][]byte{[]byte(Payload)}) values := DeserializePipelines([][]byte{[]byte(Payload)})
assert.Equal(t, 1, len(values), "Output should contain one element") assert.Equal(t, 1, len(values), "Output should contain one element")
@ -66,16 +64,16 @@ func TestVideoPipelineDeserialization(t *testing.T) {
// image pipeline steps // image pipeline steps
func TestNoSteps(t *testing.T) {
func TestExecuteSteps(t *testing.T) {
t.Run("Pipeline executes with no steps", func(t *testing.T) {
const Bucket string = "pipeline_test_01"
const Payload string = `{ const Payload string = `{
"name": "example pipeline", "name": "example pipeline",
"type": 1, "type": 1,
"removeMetadata": false, "removeMetadata": false,
"steps": [] "steps": []
}` }`
const Bucket string = "pipeline_test_04"
t.Run("Pipeline execution is successful", func(t *testing.T) {
wd, _ := os.Getwd() wd, _ := os.Getwd()
pipe := DeserializePipelines([][]byte{[]byte(Payload)})[0] pipe := DeserializePipelines([][]byte{[]byte(Payload)})[0]
@ -95,9 +93,9 @@ func TestNoSteps(t *testing.T) {
os.Remove(storageProvider.GetPath(Bucket, "source.jpg")) os.Remove(storageProvider.GetPath(Bucket, "source.jpg"))
os.Remove(storageProvider.GetPath(Bucket, dest)) os.Remove(storageProvider.GetPath(Bucket, dest))
}) })
}
func TestResizeImage(t *testing.T) {
t.Run("Image resizing is successful", func(t *testing.T) {
const Bucket string = "pipeline_test_02"
const Payload string = `{ const Payload string = `{
"name": "example pipeline", "name": "example pipeline",
"type": 1, "type": 1,
@ -114,9 +112,7 @@ func TestResizeImage(t *testing.T) {
} }
] ]
}` }`
const Bucket string = "pipeline_test_01"
t.Run("Image resizing is successful", func(t *testing.T) {
wd, _ := os.Getwd() wd, _ := os.Getwd()
pipe := DeserializePipelines([][]byte{[]byte(Payload)})[0] pipe := DeserializePipelines([][]byte{[]byte(Payload)})[0]
@ -146,9 +142,9 @@ func TestResizeImage(t *testing.T) {
os.Remove(storageProvider.GetPath(Bucket, "source.jpg")) os.Remove(storageProvider.GetPath(Bucket, "source.jpg"))
os.Remove(storageProvider.GetPath(Bucket, dest)) os.Remove(storageProvider.GetPath(Bucket, dest))
}) })
}
func TestRotateImage(t *testing.T) {
t.Run("Image rotation step is successful", func(t *testing.T) {
const Bucket string = "pipeline_test_03"
const Payload string = `{ const Payload string = `{
"name": "example pipeline", "name": "example pipeline",
"type": 1, "type": 1,
@ -163,9 +159,7 @@ func TestRotateImage(t *testing.T) {
} }
] ]
}` }`
const Bucket string = "pipeline_test_03"
t.Run("Image rotation step is successful", func(t *testing.T) {
wd, _ := os.Getwd() wd, _ := os.Getwd()
pipe := DeserializePipelines([][]byte{[]byte(Payload)})[0] pipe := DeserializePipelines([][]byte{[]byte(Payload)})[0]
@ -199,7 +193,8 @@ func TestRotateImage(t *testing.T) {
// output options // output options
func TestEncodeImageWithJpegQuality(t *testing.T) {
func TestEncoding(t *testing.T) {
const Bucket string = "pipeline_test_04"
const Payload string = `{ const Payload string = `{
"name": "example pipeline", "name": "example pipeline",
"type": 1, "type": 1,
@ -219,7 +214,6 @@ func TestEncodeImageWithJpegQuality(t *testing.T) {
"quality": 50 "quality": 50
} }
}` }`
const Bucket string = "pipeline_test_02"
t.Run("Image encoding with jpeg quality is successful", func(t *testing.T) { t.Run("Image encoding with jpeg quality is successful", func(t *testing.T) {
wd, _ := os.Getwd() wd, _ := os.Getwd()

Loading…
Cancel
Save