Skip to content

Commit

Permalink
chore(test): added precondtion tests on Rows.Close and Rows.Bind
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlangzi committed Dec 12, 2024
1 parent 8106803 commit 73e8e3c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion rows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestRowsBind(t *testing.T) {
func TestRows(t *testing.T) {

d, err := sql.Open("sqlite3", "file::memory:")
require.NoError(t, err)
Expand All @@ -36,6 +36,28 @@ func TestRowsBind(t *testing.T) {
name string
run func(t *testing.T)
}{
{
name: "close_should_always_work",
run: func(t *testing.T) {

rows := &Rows{}
rows.Close()
},
},
{
name: "bind_only_work_with_non_nil_pointer",
run: func(t *testing.T) {

rows := &Rows{}
var dest int
err := rows.Bind(dest)
require.ErrorIs(t, err, ErrMustPointer)

var dest2 *int
err = rows.Bind(dest2)
require.ErrorIs(t, err, ErrMustNotNilPointer)
},
},
{
name: "scan_on_rows_should_work",
run: func(t *testing.T) {
Expand Down

0 comments on commit 73e8e3c

Please sign in to comment.