Skip to content

Commit

Permalink
Added Types unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Elia Bracci committed Oct 20, 2023
1 parent 95ff31d commit 1052b7d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,17 @@ func TestParseProtocolFile_InvalidPath(t *testing.T) {

assert.Error(t, err)
}

func TestParseProtocol_Types(t *testing.T) {
protocol, err := avro.ParseProtocolFile("testdata/echo.avpr")

wantPing := `{"name":"org.hamba.avro.Ping","type":"record","fields":[{"name":"timestamp","type":"long"},{"name":"text","type":"string"}]}`
wantPong := `{"name":"org.hamba.avro.Pong","type":"record","fields":[{"name":"timestamp","type":"long"},{"name":"ping","type":"org.hamba.avro.Ping"}]}`
wantPongError := `{"name":"org.hamba.avro.PongError","type":"error","fields":[{"name":"timestamp","type":"long"},{"name":"reason","type":"string"}]}`
wantLen := 3
require.NoError(t, err)
assert.Equal(t, wantLen, len(protocol.Types()))
assert.Equal(t, wantPing, protocol.Types()[0].String())
assert.Equal(t, wantPong, protocol.Types()[1].String())
assert.Equal(t, wantPongError, protocol.Types()[2].String())
}

0 comments on commit 1052b7d

Please sign in to comment.