You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: pg_decryptor_test.go
    path of file: ./repos/acra/decryptor/postgresql
    
    the code of the file until where you have to start completion: package postgresql

import (
	"bufio"
	"bytes"
	"context"
	"encoding/binary"
	"encoding/hex"
	"io"
	"net"
	"testing"
	"time"

	"github.com/sirupsen/logrus"

	acracensor "github.com/cossacklabs/acra/acra-censor"
	"github.com/cossacklabs/acra/cmd/acra-server/common"
	"github.com/cossacklabs/acra/decryptor/base"
	"github.com/cossacklabs/acra/encryptor/config"
	"github.com/cossacklabs/acra/sqlparser"
)

func TestDataRowLastEmptyColumn(t *testing.T) {
	// data row packet hex dump with 5 columns and last column has length 0
	// check correct processing when last column has length 0 and packetHandler doesn't try to read from connection
	// and doesn't take io.EOF after this
	data, err := hex.DecodeString("44000001f50005000000013100000006686f746a61720000000131000001d33c212d2d20486f746a617220547261636b696e6720436f646520666f7220636f737361636b6c6162732e636f6d202d2d3e0d0a3c7363726970743e0d0a202020202866756e6374696f6e28682c6f2c742c6a2c612c72297b0d0a2020202020202020682e686a3d682e686a7c7c66756e6374696f6e28297b28682e686a2e713d682e686a2e717c7c5b5d292e7075736828617267756d656e7473297d3b0d0a2020202020202020682e5f686a53657474696e67733d7b686a69643a313137373730362c686a73763a367d3b0d0a2020202020202020613d6f2e676574456c656d656e747342795461674e616d6528276865616427295b305d3b0d0a2020202020202020723d6f2e637265617465456c656d656e74282773637269707427293b722e6173796e633d313b0d0a2020202020202020722e7372633d742b682e5f686a53657474696e67732e686a69642b6a2b682e5f686a53657474696e67732e686a73763b0d0a2020202020202020612e617070656e644368696c642872293b0d0a202020207d292877696e646f772c646f63756d656e742c2768747470733a2f2f7374617469632e686f746a61722e636f6d2f632f686f746a61722d272c272e6a733f73763d27293b0d0a3c2f7363726970743e00000000")
	if err != nil {
		t.Fatal(err)
	}
	reader := bytes.NewReader(data)
	writerBuf := bytes.NewBuffer(make([]byte, len(data)))
	writer := bufio.NewWriter(writerBuf)
	packetHandler, err := NewDbSidePacketHandler(reader, writer, logrus.NewEntry(logrus.New()))
	if err != nil {
		t.Fatal(err)
	}
	if err := packetHandler.ReadPacket(); err != nil {
		t.Fatal(err)
	}

	if !packetHandler.IsDataRow() {
		t.Fatal("Must be data row")
	}

	if err := packetHandler.parseColumns(nil); err != nil {
		t.Fatal(err)
	}
}

type testConnection struct {
	bu
    
func TestMultiplePrepareAtOnce(t *testing.T) {
	logger := logrus.NewEntry(logrus.New())
	parser := sqlparser.New(sqlparser.ModeDefault)
	ctx := context.Background()

	beginSQL := "BEGIN"
	beginName := "__cossack_begin__"

	selectSQL := "SELECT 1"
	selectName := "__cossack_select__"

	// Build two "parse" packets to simulate delivery of them at once
	clientBuffer := bytes.NewBuffer([]byte{})
	clientWriter := bufio.NewWriter(clientBuffer)
	if err := writePrepare(clientWriter, beginName, beginSQL); err != nil {
		t.Fatal(err)
	}
	if err := writePrepare(clientWriter, selectName, selectSQL); err != nil {
		t.Fatal(err)
	}
	if err := clientWriter.Flush(); err != nil {
		t.Fatal(err)
	}
	clientPacketHandler, err := NewClientSidePacketHandler(clientBuffer, nil, logger)
	if err != nil {
		t.Fatal(err)
	}
	clientPacketHandler.started = true

	// two responses one by one
	dbBuffer := bytes.NewBuffer([]byte{})
	dbWriter := bufio.NewWriter(dbBuffer)
	if err := writeZeroPrepareResponse(dbWriter); err != nil {
		t.Fatal(err)
	}
	if err := writeZeroPrepareResponse(dbWriter); err != nil {
		t.Fatal(err)
	}
	if err := dbWriter.Flush(); err != nil {
		t.Fatal(err)
	}
	dbPacketHandler, err := NewDbSidePacketHandler(dbBuffer, nil, logger)
	if err != nil {
		t.Fatal(err)
	}

	connectionSession, err := common.NewClientSession(ctx, nil, nil)
	if err != nil {
		t.Fatal(err)
	}
	proxySetting := base.NewProxySetting(parser, nil, nil, nil, acracensor.NewAcraCensor(), nil)
	proxy, err := NewPgProxy(connectionSession, parser, proxySetting)
	if err != nil {
		t.Fatal(err)
	}
	// Client packets are handled first, before responses arrive
	for {
		err := clientPacketHandler.ReadClientPacket()
		if err == io.EOF {
			break
		}
		if err != nil {
			t.Fatal(err)
		}
		_, err = proxy.handleClientPacket(ctx, clientPacketHandler, logger)
		if err != nil {
			t.Fatal(err)
		}
	}

	// Then we handle responses
	for {
		err := dbPacketHandler.ReadPacket()
		if err == io.EOF {
			break
		}
		if err != nil {
			t.Fatal(err)
		}
		err = proxy.handleDatabasePacket(ctx, dbPacketHandler, logger)
		if err != nil {
			t.Fatal(err)
		}
	}

	registry := proxy.session.PreparedStatementRegistry()
	beginStmt, err := registry.StatementByName(beginName)
	if err != nil {
		t.Fatal(err)
	}

	selectStmt, err := registry.StatementByName(selectName)
	if err != nil {
		t.Fatal(err)
	}

	if beginSQL != beginStmt.QueryText() {
		t.Fatalf("%q != %q\n", beginSQL, beginStmt.QueryText())
	}

	if selectSQL != selectStmt.QueryText() {
		t.Fatalf("%q != %q\n", selectSQL, selectStmt.QueryText())
	}
}