json_unmarshaler_test.go 715 B

12345678910111213141516171819202122232425262728293031
  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. "go.opentelemetry.io/collector/pdata/plog"
  8. )
  9. func TestNewJSONUnmarshaler(t *testing.T) {
  10. t.Parallel()
  11. um := newJSONLogsUnmarshaler()
  12. assert.Equal(t, "json", um.Encoding())
  13. }
  14. func TestPlogReturnType(t *testing.T) {
  15. t.Parallel()
  16. um := newJSONLogsUnmarshaler()
  17. json := `{"example": "example valid json to test that the unmarshaler is correctly returning a plog value"}`
  18. unmarshaledJSON, err := um.Unmarshal([]byte(json))
  19. assert.NoError(t, err)
  20. assert.Nil(t, err)
  21. var expectedType plog.Logs
  22. assert.IsType(t, expectedType, unmarshaledJSON)
  23. }