Skip to content

Commit

Permalink
Add unmarshaller test
Browse files Browse the repository at this point in the history
Signed-off-by: Davit Yeghshatyan <[email protected]>
  • Loading branch information
Davit Yeghshatyan committed Jul 19, 2018
1 parent d8ad634 commit d1565e5
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit d1565e5

Please sign in to comment.