Skip to content

Commit

Permalink
chore(test): added precondtion tests on Row.Close and Row.Bind
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlangzi committed Dec 12, 2024
1 parent 73e8e3c commit 6f59bc5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion row_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (cb *customBinder) Bind(_ reflect.Value, columns []string) []any {
return values
}

func TestRowBind(t *testing.T) {
func TestRow(t *testing.T) {

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

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

rows := &Row{}
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: "full_columns_should_work",
run: func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestRows(t *testing.T) {
}{
{
name: "close_should_always_work",
run: func(t *testing.T) {
run: func(*testing.T) {

rows := &Rows{}
rows.Close()
Expand Down

0 comments on commit 6f59bc5

Please sign in to comment.