pgx/pgproto3/copy_both_response_test.go
Jack Christensen a92f1df1df Merge remote-tracking branch 'pgproto3/master' into v5-dev
Pull in pgproto3 changes and update for pgx v5
2022-04-23 10:43:48 -05:00

19 lines
517 B
Go

package pgproto3_test
import (
"testing"
"github.com/jackc/pgx/v5/pgproto3"
"github.com/stretchr/testify/assert"
)
func TestEncodeDecode(t *testing.T) {
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")
dstBytes := []byte{}
dstBytes = dstResp.Encode(dstBytes)
assert.EqualValues(t, srcBytes, dstBytes, "Expecting src & dest bytes to match")
}