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

Function TestConnExecParams

pgconn/pgconn_test.go:1215–1240  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1213}
1214
1215func TestConnExecParams(t *testing.T) {
1216 t.Parallel()
1217
1218 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
1219 defer cancel()
1220
1221 pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
1222 require.NoError(t, err)
1223 defer closeConn(t, pgConn)
1224
1225 result := pgConn.ExecParams(ctx, "select $1::text as msg", [][]byte{[]byte("Hello, world")}, nil, nil, nil)
1226 require.Len(t, result.FieldDescriptions(), 1)
1227 assert.Equal(t, "msg", result.FieldDescriptions()[0].Name)
1228
1229 rowCount := 0
1230 for result.NextRow() {
1231 rowCount += 1
1232 assert.Equal(t, "Hello, world", string(result.Values()[0]))
1233 }
1234 assert.Equal(t, 1, rowCount)
1235 commandTag, err := result.Close()
1236 assert.Equal(t, "SELECT 1", commandTag.String())
1237 assert.NoError(t, err)
1238
1239 ensureConnValid(t, pgConn)
1240}
1241
1242func TestConnExecParamsDeferredError(t *testing.T) {
1243 t.Parallel()

Callers

nothing calls this directly

Calls 10

ConnectFunction · 0.92
NextRowMethod · 0.80
closeConnFunction · 0.70
ensureConnValidFunction · 0.70
LenMethod · 0.65
FieldDescriptionsMethod · 0.65
ValuesMethod · 0.65
CloseMethod · 0.65
ExecParamsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected