add more tests for sqlx (#442)
* add more tests for sqlx * add more tests for sqlx
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package sqlx
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/go-sql-driver/mysql"
|
||||
@@ -33,6 +35,15 @@ func TestBreakerOnNotHandlingDuplicateEntry(t *testing.T) {
|
||||
assert.True(t, found)
|
||||
}
|
||||
|
||||
func TestMysqlAcceptable(t *testing.T) {
|
||||
conn := NewMysql("nomysql").(*commonSqlConn)
|
||||
withMysqlAcceptable()(conn)
|
||||
assert.EqualValues(t, reflect.ValueOf(mysqlAcceptable).Pointer(), reflect.ValueOf(conn.accept).Pointer())
|
||||
assert.True(t, mysqlAcceptable(nil))
|
||||
assert.False(t, mysqlAcceptable(errors.New("any")))
|
||||
assert.False(t, mysqlAcceptable(new(mysql.MySQLError)))
|
||||
}
|
||||
|
||||
func tryOnDuplicateEntryError(t *testing.T, accept func(error) bool) error {
|
||||
logx.Disable()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user