File: copy_both_response_test.go

package info (click to toggle)
golang-github-jackc-pgproto3 2.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 364 kB
  • sloc: makefile: 3
file content (18 lines) | stat: -rw-r--r-- 513 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package pgproto3_test

import (
	"testing"

	"github.com/jackc/pgproto3/v2"
	"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")
}