Skip to content

Commit

Permalink
test: add test for positional params
Browse files Browse the repository at this point in the history
  • Loading branch information
marcboeker committed Jun 6, 2024
1 parent 0d97dd3 commit ddb798c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion statement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestPrepareQuery(t *testing.T) {
func TestPrepareQueryAutoIncrement(t *testing.T) {
db := openDB(t)
defer db.Close()
createFooTable(db, t)
Expand All @@ -22,6 +22,24 @@ func TestPrepareQuery(t *testing.T) {
defer rows.Close()
}

func TestPrepareQueryPositional(t *testing.T) {
db := openDB(t)
defer db.Close()
createFooTable(db, t)

stmt, err := db.Prepare("SELECT $1, $2 as foo WHERE foo=$2")
require.NoError(t, err)
defer stmt.Close()

var foo, bar int
row := stmt.QueryRow(1, 2)
require.NoError(t, err)

row.Scan(&foo, &bar)

Check failure on line 38 in statement_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `row.Scan` is not checked (errcheck)
require.Equal(t, 1, foo)
require.Equal(t, 2, bar)
}

func TestPrepareQueryNamed(t *testing.T) {
db := openDB(t)
defer db.Close()
Expand Down

0 comments on commit ddb798c

Please sign in to comment.