Micro-service for file storage and processing written in Go
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.

55 lines
1.1 KiB

  1. package pipelines
  2. import (
  3. "github.com/stretchr/testify/assert"
  4. "testing"
  5. )
  6. func TestDeserializeOptions(t *testing.T) {
  7. const Payload string = `{
  8. "name": "example pipeline",
  9. "type": 0,
  10. "removeMetadata": false,
  11. "steps": [
  12. {
  13. "name": "resize image",
  14. "type": 0,
  15. "options": {
  16. "width": 1280,
  17. "height": 720,
  18. "upscale": false
  19. }
  20. }
  21. ]
  22. }`
  23. t.Run("Image pipeline deserialization is successful", func(t *testing.T) {
  24. values := DeserializePipelines([][]byte{[]byte(Payload)})
  25. _, err := values[0].GetSteps()[0].Translate()
  26. assert.Equal(t, nil, err)
  27. })
  28. }
  29. func TestDeserializeMissingOptions(t *testing.T) {
  30. const Payload string = `{
  31. "name": "example pipeline",
  32. "type": 0,
  33. "removeMetadata": false,
  34. "steps": [
  35. {
  36. "name": "resize image",
  37. "type": 0
  38. }
  39. ]
  40. }`
  41. t.Run("Image pipeline deserialization is successful", func(t *testing.T) {
  42. values := DeserializePipelines([][]byte{[]byte(Payload)})
  43. _, err := values[0].GetSteps()[0].Translate()
  44. assert.EqualError(t, err, "unexpected end of JSON input")
  45. })
  46. }