Skip to content

Commit

Permalink
Add test for error return from Open
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Sep 27, 2021
1 parent 9347ce3 commit d2b9240
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions instrumentation/github.com/jinzhu/gorm/splunkgorm/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"database/sql"
"database/sql/driver"
"errors"
"testing"

"github.com/jinzhu/gorm"
Expand Down Expand Up @@ -67,3 +68,16 @@ func TestOpen(t *testing.T) {
assert.Equal(t, dsn, m.dataSourceName)
assert.Equal(t, options, m.options)
}

func TestOpenError(t *testing.T) {
want := errors.New("test error")
origOpen := openFunc
openFunc = func(string, string, ...splunksql.Option) (*sql.DB, error) {
return nil, want
}
defer func() { openFunc = origOpen }()

// Ensure Open returns any underlying error.
_, got := Open("", "")
assert.ErrorIs(t, got, want)
}

0 comments on commit d2b9240

Please sign in to comment.