Skip to content

Commit

Permalink
Updated to use the lastest version of github.com/DATA-DOG/go-sqlmock.
Browse files Browse the repository at this point in the history
  • Loading branch information
andymoon committed Aug 28, 2015
1 parent ee6e818 commit 1d3b96d
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 169 deletions.
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v3.1.0

* Version 3.1 [#14](https://github.com/doug-martin/goqu/pull/14) - [@andymoon](https://github.com/andymoon)
* Fix an issue with a nil pointer access on the inserts and updates.
* Allowing ScanStructs to take a struct with an embedded pointer to a struct.
* Change to check if struct is Anonymous when recursing through an embedded struct.
* Updated to use the lastest version of github.com/DATA-DOG/go-sqlmock.

## v3.0.1

* Add literal bytes and update to c2fo testify [#15](https://github.com/doug-martin/goqu/pull/15) - [@TechnotronicOz](https://github.com/TechnotronicOz)
Expand Down
4 changes: 2 additions & 2 deletions crud_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func assignVals(i interface{}, results []Record, cm columnMap) error {
val := reflect.Indirect(reflect.ValueOf(i))
t, _, isSliceOfPointers := getTypeInfo(i, val)
switch val.Kind() {
case reflect.Struct:
case reflect.Struct:
result := results[0]
for name, data := range cm {
src, ok := result[name]
Expand All @@ -234,7 +234,7 @@ func assignVals(i interface{}, results []Record, cm columnMap) error {
}
}
}
case reflect.Slice:
case reflect.Slice:
for _, result := range results {
row := reflect.Indirect(reflect.New(t))
initEmbeddedPtr(row)
Expand Down
42 changes: 21 additions & 21 deletions crud_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/DATA-DOG/go-sqlmock"
"gopkg.in/DATA-DOG/go-sqlmock.v1"
"github.com/c2fo/testify/assert"
"github.com/c2fo/testify/suite"
)
Expand All @@ -31,7 +31,7 @@ type crudExecTest struct {

func (me *crudExecTest) TestWithError() {
t := me.T()
mDb, err := sqlmock.New()
mDb, _, err := sqlmock.New()
assert.NoError(t, err)
db := New("db-mock", mDb)
expectedErr := fmt.Errorf("crud exec error")
Expand All @@ -51,29 +51,29 @@ func (me *crudExecTest) TestWithError() {

func (me *crudExecTest) TestScanStructs() {
t := me.T()
mDb, err := sqlmock.New()
mDb, mock, err := sqlmock.New()
assert.NoError(t, err)

sqlmock.ExpectQuery(`SELECT \* FROM "items"`).
mock.ExpectQuery(`SELECT \* FROM "items"`).
WillReturnError(fmt.Errorf("query error"))

sqlmock.ExpectQuery(`SELECT \* FROM "items"`).
mock.ExpectQuery(`SELECT \* FROM "items"`).
WithArgs().
WillReturnRows(sqlmock.NewRows([]string{"address", "name"}).FromCSVString("111 Test Addr,Test1\n211 Test Addr,Test2"))

sqlmock.ExpectQuery(`SELECT \* FROM "items"`).
mock.ExpectQuery(`SELECT \* FROM "items"`).
WithArgs().
WillReturnRows(sqlmock.NewRows([]string{"address", "name", "phone_number", "age"}).FromCSVString("111 Test Addr,Test1,111-111-1111,20\n211 Test Addr,Test2,222-222-2222,30"))

sqlmock.ExpectQuery(`SELECT \* FROM "items"`).
mock.ExpectQuery(`SELECT \* FROM "items"`).
WithArgs().
WillReturnRows(sqlmock.NewRows([]string{"address", "name"}).FromCSVString("111 Test Addr,Test1\n211 Test Addr,Test2"))

sqlmock.ExpectQuery(`SELECT \* FROM "items"`).
mock.ExpectQuery(`SELECT \* FROM "items"`).
WithArgs().
WillReturnRows(sqlmock.NewRows([]string{"address", "name", "phone_number", "age"}).FromCSVString("111 Test Addr,Test1,111-111-1111,20\n211 Test Addr,Test2,222-222-2222,30"))

sqlmock.ExpectQuery(`SELECT \* FROM "items"`).
mock.ExpectQuery(`SELECT \* FROM "items"`).
WithArgs().
WillReturnRows(sqlmock.NewRows([]string{"address", "name"}).FromCSVString("111 Test Addr,Test1\n211 Test Addr,Test2"))

Expand Down Expand Up @@ -141,21 +141,21 @@ func (me *crudExecTest) TestScanStructs() {

func (me *crudExecTest) TestScanStruct() {
t := me.T()
mDb, err := sqlmock.New()
mDb, mock, err := sqlmock.New()
assert.NoError(t, err)

sqlmock.ExpectQuery(`SELECT \* FROM "items"`).
mock.ExpectQuery(`SELECT \* FROM "items"`).
WillReturnError(fmt.Errorf("query error"))

sqlmock.ExpectQuery(`SELECT \* FROM "items"`).
mock.ExpectQuery(`SELECT \* FROM "items"`).
WithArgs().
WillReturnRows(sqlmock.NewRows([]string{"address", "name"}).FromCSVString("111 Test Addr,Test1"))

sqlmock.ExpectQuery(`SELECT \* FROM "items"`).
mock.ExpectQuery(`SELECT \* FROM "items"`).
WithArgs().
WillReturnRows(sqlmock.NewRows([]string{"address", "name", "phone_number", "age"}).FromCSVString("111 Test Addr,Test1,111-111-1111,20"))

sqlmock.ExpectQuery(`SELECT \* FROM "items"`).
mock.ExpectQuery(`SELECT \* FROM "items"`).
WithArgs().
WillReturnRows(sqlmock.NewRows([]string{"address", "name"}).FromCSVString("111 Test Addr,Test1"))

Expand Down Expand Up @@ -199,17 +199,17 @@ func (me *crudExecTest) TestScanStruct() {

func (me *crudExecTest) TestScanVals() {
t := me.T()
mDb, err := sqlmock.New()
mDb, mock, err := sqlmock.New()
assert.NoError(t, err)

sqlmock.ExpectQuery(`SELECT "id" FROM "items"`).
mock.ExpectQuery(`SELECT "id" FROM "items"`).
WillReturnError(fmt.Errorf("query error"))

sqlmock.ExpectQuery(`SELECT "id" FROM "items"`).
mock.ExpectQuery(`SELECT "id" FROM "items"`).
WithArgs().
WillReturnRows(sqlmock.NewRows([]string{"id"}).FromCSVString("1\n2"))

sqlmock.ExpectQuery(`SELECT "id" FROM "items"`).
mock.ExpectQuery(`SELECT "id" FROM "items"`).
WithArgs().
WillReturnRows(sqlmock.NewRows([]string{"id"}).FromCSVString("1\n2"))

Expand All @@ -234,13 +234,13 @@ func (me *crudExecTest) TestScanVals() {

func (me *crudExecTest) TestScanVal() {
t := me.T()
mDb, err := sqlmock.New()
mDb, mock, err := sqlmock.New()
assert.NoError(t, err)

sqlmock.ExpectQuery(`SELECT "id" FROM "items"`).
mock.ExpectQuery(`SELECT "id" FROM "items"`).
WillReturnError(fmt.Errorf("query error"))

sqlmock.ExpectQuery(`SELECT "id" FROM "items"`).
mock.ExpectQuery(`SELECT "id" FROM "items"`).
WithArgs().
WillReturnRows(sqlmock.NewRows([]string{"id"}).FromCSVString("1"))

Expand Down
Loading

0 comments on commit 1d3b96d

Please sign in to comment.