Skip to content

Commit

Permalink
Improving deserializer testing
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffrey Beausire <g.beausire@criteo.com>
  • Loading branch information
geobeau committed Dec 17, 2018
1 parent abf8a9a commit a273a5c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions model/converter/thrift/zipkin/deserialize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,16 @@ func TestDeserializeWithBadListStart(t *testing.T) {
_, err := DeserializeThrift(append([]byte{0, 255, 255}, spanBytes...))
assert.Error(t, err)
}

func TestDeserializeWithCorruptedList(t *testing.T) {
spanBytes := ZipkinSerialize([]*zipkincore.Span{{}})
spanBytes[2] = 255
_, err := DeserializeThrift(spanBytes)
assert.Error(t, err)
}

func TestDeserialize(t *testing.T) {
spanBytes := ZipkinSerialize([]*zipkincore.Span{{}})
_, err := DeserializeThrift(spanBytes)
assert.NoError(t, err)
}
9 changes: 6 additions & 3 deletions plugin/storage/kafka/marshalling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,21 @@ func testMarshallerAndUnmarshaller(t *testing.T, marshaller Marshaller, unmarsha
}

func TestZipkinThriftUnmarshaller(t *testing.T) {
operationName := "foo"
bytes := zipkin.ZipkinSerialize([]*zipkincore.Span{
{
ID: 12345,
Name: "foo",
Name: operationName,
Annotations: []*zipkincore.Annotation{
{Host: &zipkincore.Endpoint{ServiceName: "foo"}},
{Host: &zipkincore.Endpoint{ServiceName: "foobar"}},
},
},
})
unmarshaller := NewZipkinThriftUnmarshaller()
_, err := unmarshaller.Unmarshal(bytes)
resultSpan, err := unmarshaller.Unmarshal(bytes)

assert.NoError(t, err)
assert.Equal(t, operationName, resultSpan.OperationName)
}

func TestZipkinThriftUnmarshallerErrorNoService(t *testing.T) {
Expand Down

0 comments on commit a273a5c

Please sign in to comment.