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

Function TestConnExec

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

Source from the content-addressed store, hash-verified

996}
997
998func TestConnExec(t *testing.T) {
999 t.Parallel()
1000
1001 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
1002 defer cancel()
1003
1004 pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
1005 require.NoError(t, err)
1006 defer closeConn(t, pgConn)
1007
1008 results, err := pgConn.Exec(ctx, "select 'Hello, world'").ReadAll()
1009 assert.NoError(t, err)
1010
1011 assert.Len(t, results, 1)
1012 assert.Nil(t, results[0].Err)
1013 assert.Equal(t, "SELECT 1", results[0].CommandTag.String())
1014 assert.Len(t, results[0].Rows, 1)
1015 assert.Equal(t, "Hello, world", string(results[0].Rows[0][0]))
1016
1017 ensureConnValid(t, pgConn)
1018}
1019
1020func TestConnExecEmpty(t *testing.T) {
1021 t.Parallel()

Callers

nothing calls this directly

Calls 7

ConnectFunction · 0.92
ReadAllMethod · 0.80
closeConnFunction · 0.70
ensureConnValidFunction · 0.70
ExecMethod · 0.65
LenMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected