acme-dns/vendor/github.com/erikstmartin/go-testdb/tx.go
Joona Hoikkala fd9ce4606d
Get rid of Iris and use julienschmidt/httprouter instead (#20)
* Replace iris with httprouter

* Linter fixes

* Finalize iris removal

* Vendor dependencies for reproducable builds

* Api tests are back
2017-11-14 23:54:29 +02:00

41 lines
619 B
Go

package testdb
type Tx struct {
commitFunc func() error
rollbackFunc func() error
}
func (t *Tx) Commit() error {
if t.commitFunc != nil {
return t.commitFunc()
}
return nil
}
func (t *Tx) Rollback() error {
if t.rollbackFunc != nil {
return t.rollbackFunc()
}
return nil
}
func (t *Tx) SetCommitFunc(f func() error) {
t.commitFunc = f
}
func (t *Tx) StubCommitError(err error) {
t.SetCommitFunc(func() error {
return err
})
}
func (t *Tx) SetRollbackFunc(f func() error) {
t.rollbackFunc = f
}
func (t *Tx) StubRollbackError(err error) {
t.SetRollbackFunc(func() error {
return err
})
}