From d1565e5aa13c251b65ccc4beea7d5609e7c675d8 Mon Sep 17 00:00:00 2001 From: Davit Yeghshatyan Date: Thu, 19 Jul 2018 13:14:55 -0400 Subject: [PATCH] Add unmarshaller test Signed-off-by: Davit Yeghshatyan --- ...{marshaller_test.go => marshalling_test.go} | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) rename plugin/storage/kafka/{marshaller_test.go => marshalling_test.go} (63%) diff --git a/plugin/storage/kafka/marshaller_test.go b/plugin/storage/kafka/marshalling_test.go similarity index 63% rename from plugin/storage/kafka/marshaller_test.go rename to plugin/storage/kafka/marshalling_test.go index 785551ea641b..8b0d8139dc45 100644 --- a/plugin/storage/kafka/marshaller_test.go +++ b/plugin/storage/kafka/marshalling_test.go @@ -20,20 +20,22 @@ import ( "github.com/stretchr/testify/assert" ) -func TestProtoMarshaller(t *testing.T) { - marshaller := newProtobufMarshaller() +func TestProtobufMarshallerAndUnmarshaller(t *testing.T) { + testMarshallerAndUnmarshaller(t,newProtobufMarshaller(),NewProtobufUnmarshaller()) +} + +func TestJSONMarshallerAndUnmarshaller(t *testing.T) { + testMarshallerAndUnmarshaller(t,newJSONMarshaller(),NewJSONUnmarshaller()) +} +func testMarshallerAndUnmarshaller(t *testing.T, marshaller Marshaller, unmarshaller Unmarshaller) { bytes, err := marshaller.Marshal(sampleSpan) assert.NoError(t, err) assert.NotNil(t, bytes) -} -func TestJSONMarshaller(t *testing.T) { - marshaller := newJSONMarshaller() - - bytes, err := marshaller.Marshal(sampleSpan) + resultSpan, err := unmarshaller.Unmarshal(bytes) assert.NoError(t, err) - assert.NotNil(t, bytes) + assert.Equal(t, sampleSpan, resultSpan) }