MCPcopy
hub / github.com/jackc/pgx / TestConnectWithPreferSimpleProtocol

Function TestConnectWithPreferSimpleProtocol

conn_test.go:86–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

84}
85
86func TestConnectWithPreferSimpleProtocol(t *testing.T) {
87 t.Parallel()
88
89 connConfig := mustParseConfig(t, os.Getenv("PGX_TEST_DATABASE"))
90 connConfig.DefaultQueryExecMode = pgx.QueryExecModeSimpleProtocol
91
92 conn := mustConnect(t, connConfig)
93 defer closeConn(t, conn)
94
95 // If simple protocol is used we should be able to correctly scan the result
96 // into a pgtype.Text as the integer will have been encoded in text.
97
98 var s pgtype.Text
99 err := conn.QueryRow(context.Background(), "select $1::int4", 42).Scan(&s)
100 require.NoError(t, err)
101 require.Equal(t, pgtype.Text{String: "42", Valid: true}, s)
102
103 ensureConnValid(t, conn)
104}
105
106func TestConnectConfigRequiresConnConfigFromParseConfig(t *testing.T) {
107 config := &pgx.ConnConfig{}

Callers

nothing calls this directly

Calls 6

mustParseConfigFunction · 0.70
mustConnectFunction · 0.70
closeConnFunction · 0.70
ensureConnValidFunction · 0.70
ScanMethod · 0.65
QueryRowMethod · 0.65

Tested by

no test coverage detected