1
0
mirror of https://github.com/zhashkevych/go-sqlxmock.git synced 2024-11-24 08:12:13 +02:00
go-sqlxmock/result.go

31 lines
579 B
Go
Raw Normal View History

2014-02-05 17:21:07 +03:00
package sqlmock
2014-02-08 18:51:58 +03:00
import (
"database/sql/driver"
2014-02-08 18:51:58 +03:00
)
2014-02-07 11:44:41 +03:00
// Result satisfies sql driver Result, which
2014-02-07 09:58:27 +03:00
// holds last insert id and rows affected
2014-02-07 11:44:41 +03:00
// by Exec queries
2014-02-08 18:51:58 +03:00
type result struct {
insertID int64
2014-02-05 17:21:07 +03:00
rowsAffected int64
}
2014-02-08 18:51:58 +03:00
// NewResult creates a new sql driver Result
// for Exec based query mocks.
func NewResult(lastInsertID int64, rowsAffected int64) driver.Result {
return &result{
lastInsertID,
2014-02-05 17:21:07 +03:00
rowsAffected,
}
}
2014-02-08 18:51:58 +03:00
func (r *result) LastInsertId() (int64, error) {
return r.insertID, nil
2014-02-05 17:21:07 +03:00
}
2014-02-08 18:51:58 +03:00
func (r *result) RowsAffected() (int64, error) {
return r.rowsAffected, nil
2014-02-05 17:21:07 +03:00
}