support postgresql (#583)

support postgresql
This commit is contained in:
Kevin Wan
2021-03-27 17:14:32 +08:00
committed by GitHub
parent 9e6c2ba2c0
commit bd623aaac3
5 changed files with 59 additions and 44 deletions

View File

@@ -16,7 +16,6 @@ func TestStmt_exec(t *testing.T) {
name string
args []interface{}
delay bool
formatError bool
hasError bool
err error
lastInsertId int64
@@ -28,12 +27,6 @@ func TestStmt_exec(t *testing.T) {
lastInsertId: 1,
rowsAffected: 2,
},
{
name: "wrong format",
args: []interface{}{1, 2},
formatError: true,
hasError: true,
},
{
name: "exec error",
args: []interface{}{1},
@@ -70,18 +63,13 @@ func TestStmt_exec(t *testing.T) {
},
}
for i, fn := range fns {
i := i
for _, fn := range fns {
fn := fn
t.Run(test.name, func(t *testing.T) {
t.Parallel()
res, err := fn(test.args...)
if i == 0 && test.formatError {
assert.NotNil(t, err)
return
}
if !test.formatError && test.hasError {
if test.hasError {
assert.NotNil(t, err)
return
}
@@ -100,23 +88,16 @@ func TestStmt_exec(t *testing.T) {
func TestStmt_query(t *testing.T) {
tests := []struct {
name string
args []interface{}
delay bool
formatError bool
hasError bool
err error
name string
args []interface{}
delay bool
hasError bool
err error
}{
{
name: "normal",
args: []interface{}{1},
},
{
name: "wrong format",
args: []interface{}{1, 2},
formatError: true,
hasError: true,
},
{
name: "query error",
args: []interface{}{1},
@@ -151,18 +132,13 @@ func TestStmt_query(t *testing.T) {
},
}
for i, fn := range fns {
i := i
for _, fn := range fns {
fn := fn
t.Run(test.name, func(t *testing.T) {
t.Parallel()
err := fn(test.args...)
if i == 0 && test.formatError {
assert.NotNil(t, err)
return
}
if !test.formatError && test.hasError {
if test.hasError {
assert.NotNil(t, err)
return
}