2
0
Files
pgx/pgproto3/copy_both_response_test.go
2024-05-07 09:50:32 +03:00

21 lines
591 B
Go

package pgproto3_test
import (
"testing"
"git.company.lan/gopkg/pgx/v5/pgproto3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
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, err = dstResp.Encode(dstBytes)
require.NoError(t, err)
assert.EqualValues(t, srcBytes, dstBytes, "Expecting src & dest bytes to match")
}