...

Source file src/github.com/jackc/pgx/v5/pgproto3/copy_both_response_test.go

Documentation: github.com/jackc/pgx/v5/pgproto3

     1  package pgproto3_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/jackc/pgx/v5/pgproto3"
     7  	"github.com/stretchr/testify/assert"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func TestEncodeDecode(t *testing.T) {
    12  	srcBytes := []byte{'W', 0x00, 0x00, 0x00, 0x0b, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}
    13  	dstResp := pgproto3.CopyBothResponse{}
    14  	err := dstResp.Decode(srcBytes[5:])
    15  	assert.NoError(t, err, "No errors on decode")
    16  	dstBytes := []byte{}
    17  	dstBytes, err = dstResp.Encode(dstBytes)
    18  	require.NoError(t, err)
    19  	assert.EqualValues(t, srcBytes, dstBytes, "Expecting src & dest bytes to match")
    20  }
    21  

View as plain text