1
0
mirror of https://github.com/DATA-DOG/go-sqlmock.git synced 2025-04-23 11:58:47 +02:00

Add go-sql-driver imports to make it easier to run the examples

This commit is contained in:
Theo 2019-02-27 17:04:14 +00:00
parent 7f7699b45e
commit 05afef726f
4 changed files with 15 additions and 4 deletions

View File

@ -32,17 +32,21 @@ See **.travis.yml** for supported **go** versions.
Different use case, is to functionally test with a real database - [go-txdb](https://github.com/DATA-DOG/go-txdb)
all database related actions are isolated within a single transaction so the database can remain in the same state.
See implementation examples:
See implementation examples:
- [blog API server](https://github.com/DATA-DOG/go-sqlmock/tree/master/examples/blog)
- [the same orders example](https://github.com/DATA-DOG/go-sqlmock/tree/master/examples/orders)
### Something you may want to test
### Something you may want to test, assuming you use the [go-mysql-driver](https://github.com/go-sql-driver/mysql)
``` go
package main
import "database/sql"
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func recordStats(db *sql.DB, userID, productID int64) (err error) {
tx, err := db.Begin()

View File

@ -1,6 +1,10 @@
package main
import "database/sql"
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func recordStats(db *sql.DB, userID, productID int64) (err error) {
tx, err := db.Begin()

View File

@ -4,6 +4,8 @@ import (
"database/sql"
"encoding/json"
"net/http"
_ "github.com/go-sql-driver/mysql"
)
type api struct {

View File

@ -6,6 +6,7 @@ import (
"log"
"github.com/kisielk/sqlstruct"
_ "github.com/go-sql-driver/mysql"
)
const ORDER_PENDING = 0