Skip to content

Commit

Permalink
Addressing feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Mukundan Kavanur Kidambi authored and jackc committed Apr 2, 2022
1 parent e145003 commit c6ccb4b
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions copy_both_response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ import (
)

func TestEncodeDecode(t *testing.T) {
src := pgproto3.CopyBothResponse{
OverallFormat: byte(1), // Just to differ from defaults
ColumnFormatCodes: []uint16{0, 1},
}
dstBytes := []byte{}
dstBytes = src.Encode(dstBytes)
dst := pgproto3.CopyBothResponse{}
err := dst.Decode(dstBytes[5:])
srcBytes := []byte{'W', 0x00, 0x00, 0x00, 0x0b, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}
dstResp := pgproto3.CopyBothResponse{}
err := dstResp.Decode(srcBytes[5:])
assert.NoError(t, err, "No errors on decode")
assert.Equal(t, dst.OverallFormat, src.OverallFormat, "OverallFormat is decoded successfully")
assert.EqualValues(t, dst.ColumnFormatCodes, src.ColumnFormatCodes)
dstBytes := []byte{}
dstBytes = dstResp.Encode(dstBytes)
assert.EqualValues(t, srcBytes, dstBytes, "Expecting src & dest bytes to match")
}

0 comments on commit c6ccb4b

Please sign in to comment.