FAQ
Hello,

I'm trying to write a wrapper for database/sql/driver to be able to use it
in tests. The general idea for now is to be able to say to this wrapper
driver to fail Nth query. I have done proof of concept but I can't seem to
solve a problem of wrapping transaction. For now my code looks like this:

https://github.com/rzajac/goassert/blob/database_sql/dbwrap/conn.go#L13-L16

I can force Commit and Rollback to fail but have problems writing
passthrough methods for Query, Exec, ...

https://github.com/rzajac/goassert/blob/database_sql/dbwrap/conn.go#L65-L71

And this is how I initialize it in the code:

import (
"database/sql"
"database/sql/driver"
"github.com/rzajac/goassert/dbwrap"
"github.com/ziutek/mymysql/godrv"
)


var drv driver.Driver = &godrv.Driver{}
testDbWr = dbwrap.New("testing", drv)
// use the new name to connect
testDb, err = sql.Open("testing", connectString)

Do you guys have any suggestions how to do it?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 4, '14 at 11:30p
activeApr 5, '14 at 10:30a
posts3
users2
websitegolang.org

2 users in discussion

Ralph Zajac: 2 posts Tamás Gulácsi: 1 post

People

Translate

site design / logo © 2021 Grokbase