mirror of
https://github.com/DATA-DOG/go-sqlmock.git
synced 2024-11-28 08:49:01 +02:00
commit
c05e0c0b97
2
query.go
2
query.go
@ -15,7 +15,7 @@ func stripQuery(q string) (s string) {
|
||||
|
||||
// QueryMatcher is an SQL query string matcher interface,
|
||||
// which can be used to customize validation of SQL query strings.
|
||||
// As an exaple, external library could be used to build
|
||||
// As an example, external library could be used to build
|
||||
// and validate SQL ast, columns selected.
|
||||
//
|
||||
// sqlmock can be customized to implement a different QueryMatcher
|
||||
|
@ -35,21 +35,21 @@ func TestShouldReturnValidSqlDriverResult(t *testing.T) {
|
||||
result := NewResult(1, 2)
|
||||
id, err := result.LastInsertId()
|
||||
if 1 != id {
|
||||
t.Errorf("Expected last insert id to be 1, but got: %d", id)
|
||||
t.Errorf("expected last insert id to be 1, but got: %d", id)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("expected no error, but got: %s", err)
|
||||
}
|
||||
affected, err := result.RowsAffected()
|
||||
if 2 != affected {
|
||||
t.Errorf("Expected affected rows to be 2, but got: %d", affected)
|
||||
t.Errorf("expected affected rows to be 2, but got: %d", affected)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("expected no error, but got: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldReturnErroeSqlDriverResult(t *testing.T) {
|
||||
func TestShouldReturnErrorSqlDriverResult(t *testing.T) {
|
||||
result := NewErrorResult(fmt.Errorf("some error"))
|
||||
_, err := result.LastInsertId()
|
||||
if err == nil {
|
||||
|
2
rows.go
2
rows.go
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// CSVColumnParser is a function which converts trimmed csv
|
||||
// column string to a []byte representation. currently
|
||||
// column string to a []byte representation. Currently
|
||||
// transforms NULL to nil
|
||||
var CSVColumnParser = func(s string) []byte {
|
||||
switch {
|
||||
|
@ -118,7 +118,7 @@ func (c *sqlmock) MatchExpectationsInOrder(b bool) {
|
||||
}
|
||||
|
||||
// Close a mock database driver connection. It may or may not
|
||||
// be called depending on the sircumstances, but if it is called
|
||||
// be called depending on the circumstances, but if it is called
|
||||
// there must be an *ExpectedClose expectation satisfied.
|
||||
// meets http://golang.org/pkg/database/sql/driver/#Conn interface
|
||||
func (c *sqlmock) Close() error {
|
||||
|
@ -114,7 +114,7 @@ func TestMockQuery(t *testing.T) {
|
||||
|
||||
defer func() {
|
||||
if er := rows.Close(); er != nil {
|
||||
t.Error("Unexpected error while trying to close rows")
|
||||
t.Error("unexpected error while trying to close rows")
|
||||
}
|
||||
}()
|
||||
|
||||
@ -167,7 +167,7 @@ func TestMockQueryTypes(t *testing.T) {
|
||||
}
|
||||
defer func() {
|
||||
if er := rows.Close(); er != nil {
|
||||
t.Error("Unexpected error while trying to close rows")
|
||||
t.Error("unexpected error while trying to close rows")
|
||||
}
|
||||
}()
|
||||
if !rows.Next() {
|
||||
@ -615,7 +615,7 @@ func TestArgumentReflectValueTypeError(t *testing.T) {
|
||||
|
||||
_, err = db.Query("SELECT * FROM sales WHERE x = ?", 5)
|
||||
if err == nil {
|
||||
t.Error("Expected error, but got none")
|
||||
t.Error("expected error, but got none")
|
||||
}
|
||||
}
|
||||
|
||||
@ -782,7 +782,7 @@ func TestEmptyRowSet(t *testing.T) {
|
||||
|
||||
defer func() {
|
||||
if er := rows.Close(); er != nil {
|
||||
t.Error("Unexpected error while trying to close rows")
|
||||
t.Error("unexpected error while trying to close rows")
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExpectedPreparedStatemtCloseError(t *testing.T) {
|
||||
func TestExpectedPreparedStatementCloseError(t *testing.T) {
|
||||
conn, mock, err := New()
|
||||
if err != nil {
|
||||
t.Fatal("failed to open sqlmock database:", err)
|
||||
@ -28,6 +28,6 @@ func TestExpectedPreparedStatemtCloseError(t *testing.T) {
|
||||
}
|
||||
|
||||
if err := stmt.Close(); err != want {
|
||||
t.Fatalf("Got = %v, want = %v", err, want)
|
||||
t.Fatalf("got = %v, want = %v", err, want)
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ func (ni *NullInt) Scan(value interface{}) error {
|
||||
ni.Integer, ni.Valid = 0, false
|
||||
case int64:
|
||||
const maxUint = ^uint(0)
|
||||
const minUint = 0
|
||||
const maxInt = int(maxUint >> 1)
|
||||
const minInt = -maxInt - 1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user