text_unmarshaler_test.go 713 B

12345678910111213141516171819202122232425262728293031323334
  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 TestNewTextUnmarshaler(t *testing.T) {
  10. t.Parallel()
  11. um := newTextLogsUnmarshaler()
  12. assert.Equal(t, "text", um.Encoding())
  13. }
  14. func TestTextUnmarshalerWithEnc(t *testing.T) {
  15. t.Parallel()
  16. um := newTextLogsUnmarshaler()
  17. um2 := um
  18. assert.EqualValues(t, um, um2)
  19. um, err := um.WithEnc("utf8")
  20. require.NoError(t, err)
  21. um2, err = um2.WithEnc("gbk")
  22. require.NoError(t, err)
  23. assert.NotEqualValues(t, um, um2)
  24. um2, err = um2.WithEnc("utf8")
  25. require.NoError(t, err)
  26. assert.EqualValues(t, um, um2)
  27. }