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.

78 lines
1.5 KiB

  1. package pipelines
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestDeserializeOptionsResizeImage(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].GetExecutable()
  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].GetExecutable()
  44. assert.EqualError(t, err, "unexpected end of JSON input")
  45. })
  46. }
  47. func TestLoadingImage(t *testing.T) {
  48. const Payload string = `{
  49. "name": "example pipeline",
  50. "type": 0,
  51. "removeMetadata": false,
  52. "steps": [
  53. {
  54. "name": "resize image",
  55. "type": 0
  56. }
  57. ]
  58. }`
  59. t.Run("Loading image from filesystem to pipeline is successful", func(t *testing.T) {
  60. values := DeserializePipelines([][]byte{[]byte(Payload)})
  61. _, err := values[0].GetSteps()[0].GetExecutable()
  62. assert.EqualError(t, err, "unexpected end of JSON input")
  63. })
  64. }