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.

58 lines
1.4 KiB

  1. package main
  2. import (
  3. "github.com/stretchr/testify/assert"
  4. "testing"
  5. )
  6. const ValidImagePayload string = `{
  7. "name": "example pipeline",
  8. "type": 0,
  9. "removeMetadata": false,
  10. "steps": [
  11. {
  12. "name": "resize image",
  13. "type": 0
  14. },
  15. {
  16. "name": "compress image",
  17. "type": 1
  18. }
  19. ]
  20. }`
  21. func TestImagePipelineDeserialization(t *testing.T) {
  22. t.Run("Image pipeline deserialization is successful", func(t *testing.T) {
  23. values := DeserializePipelines([][]byte{[]byte(ValidImagePayload)})
  24. assert.Equal(t, 1, len(values), "Output should contain one element")
  25. assert.Equal(t, "example pipeline", values[0].GetName())
  26. assert.Equal(t, Image, values[0].GetType())
  27. })
  28. }
  29. const ValidVideoPayload string = `{
  30. "name": "example pipeline",
  31. "type": 1,
  32. "removeMetadata": false,
  33. "steps": [
  34. {
  35. "name": "resize image",
  36. "type": 0
  37. },
  38. {
  39. "name": "compress image",
  40. "type": 1
  41. }
  42. ]
  43. }`
  44. func TestVideoPipelineDeserialization(t *testing.T) {
  45. t.Run("Video pipelines deserialization is successful", func(t *testing.T) {
  46. values := DeserializePipelines([][]byte{[]byte(ValidVideoPayload)})
  47. assert.Equal(t, 1, len(values), "Output should contain one element")
  48. assert.Equal(t, "example pipeline", values[0].GetName())
  49. assert.Equal(t, Video, values[0].GetType())
  50. })
  51. }