...

Source file src/github.com/jackc/pgproto3/v2/query_test.go

Documentation: github.com/jackc/pgproto3/v2

     1  package pgproto3_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/jackc/pgproto3/v2"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func TestQueryBiggerThanMaxMessageBodyLen(t *testing.T) {
    11  	t.Parallel()
    12  
    13  	// Maximum allowed size. 4 bytes for size and 1 byte for 0 terminated string.
    14  	_, err := (&pgproto3.Query{String: string(make([]byte, pgproto3.MaxMessageBodyLen-5))}).Encode(nil)
    15  	require.NoError(t, err)
    16  
    17  	// 1 byte too big
    18  	_, err = (&pgproto3.Query{String: string(make([]byte, pgproto3.MaxMessageBodyLen-4))}).Encode(nil)
    19  	require.Error(t, err)
    20  }
    21  

View as plain text