https://github.com/jackc/pgx/issues/859
(t *testing.T)
| 1395 | |
| 1396 | // https://github.com/jackc/pgx/issues/859 |
| 1397 | func TestResultReaderValuesHaveSameCapacityAsLength(t *testing.T) { |
| 1398 | t.Parallel() |
| 1399 | |
| 1400 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) |
| 1401 | defer cancel() |
| 1402 | |
| 1403 | pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE")) |
| 1404 | require.NoError(t, err) |
| 1405 | defer closeConn(t, pgConn) |
| 1406 | |
| 1407 | result := pgConn.ExecParams(ctx, "select $1::text as msg", [][]byte{[]byte("Hello, world")}, nil, nil, nil) |
| 1408 | require.Len(t, result.FieldDescriptions(), 1) |
| 1409 | assert.Equal(t, "msg", result.FieldDescriptions()[0].Name) |
| 1410 | |
| 1411 | rowCount := 0 |
| 1412 | for result.NextRow() { |
| 1413 | rowCount += 1 |
| 1414 | assert.Equal(t, "Hello, world", string(result.Values()[0])) |
| 1415 | assert.Equal(t, len(result.Values()[0]), cap(result.Values()[0])) |
| 1416 | } |
| 1417 | assert.Equal(t, 1, rowCount) |
| 1418 | commandTag, err := result.Close() |
| 1419 | assert.Equal(t, "SELECT 1", commandTag.String()) |
| 1420 | assert.NoError(t, err) |
| 1421 | |
| 1422 | ensureConnValid(t, pgConn) |
| 1423 | } |
| 1424 | |
| 1425 | // https://github.com/jackc/pgx/issues/1987 |
| 1426 | func TestResultReaderReadNil(t *testing.T) { |
nothing calls this directly
no test coverage detected