1
0
mirror of https://github.com/DATA-DOG/go-sqlmock.git synced 2025-06-14 23:55:00 +02:00
This commit is contained in:
gedi
2014-04-21 18:21:28 +03:00
parent 2e154ee410
commit fa31f407df
3 changed files with 36 additions and 3 deletions

View File

@ -85,6 +85,19 @@ func init() {
sql.Register("mock", mock)
}
// New creates sqlmock database connection
// and pings it so that all expectations could be
// asserted on Close.
func New() (db *sql.DB, err error) {
db, err = sql.Open("mock", "")
if err != nil {
return
}
// ensure open connection, otherwise Close does not assert expectations
db.Ping()
return
}
// ExpectBegin expects transaction to be started
func ExpectBegin() Mock {
e := &expectedBegin{}