unmarshaler_test.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package kafkareceiver
  4. import (
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. "github.com/stretchr/testify/require"
  8. )
  9. func TestDefaultTracesUnMarshaler(t *testing.T) {
  10. expectedEncodings := []string{
  11. "otlp_proto",
  12. "jaeger_proto",
  13. "jaeger_json",
  14. "zipkin_proto",
  15. "zipkin_json",
  16. "zipkin_thrift",
  17. }
  18. marshalers := defaultTracesUnmarshalers()
  19. assert.Equal(t, len(expectedEncodings), len(marshalers))
  20. for _, e := range expectedEncodings {
  21. t.Run(e, func(t *testing.T) {
  22. m, ok := marshalers[e]
  23. require.True(t, ok)
  24. assert.NotNil(t, m)
  25. })
  26. }
  27. }
  28. func TestDefaultMetricsUnMarshaler(t *testing.T) {
  29. expectedEncodings := []string{
  30. "otlp_proto",
  31. }
  32. marshalers := defaultMetricsUnmarshalers()
  33. assert.Equal(t, len(expectedEncodings), len(marshalers))
  34. for _, e := range expectedEncodings {
  35. t.Run(e, func(t *testing.T) {
  36. m, ok := marshalers[e]
  37. require.True(t, ok)
  38. assert.NotNil(t, m)
  39. })
  40. }
  41. }
  42. func TestDefaultLogsUnMarshaler(t *testing.T) {
  43. expectedEncodings := []string{
  44. "otlp_proto",
  45. "raw",
  46. "text",
  47. "json",
  48. }
  49. marshalers := defaultLogsUnmarshalers()
  50. assert.Equal(t, len(expectedEncodings), len(marshalers))
  51. for _, e := range expectedEncodings {
  52. t.Run(e, func(t *testing.T) {
  53. m, ok := marshalers[e]
  54. require.True(t, ok)
  55. assert.NotNil(t, m)
  56. })
  57. }
  58. }