mirror of
https://github.com/joohoi/acme-dns.git
synced 2025-01-13 08:15:18 +07:00
fd9ce4606d
* Replace iris with httprouter * Linter fixes * Finalize iris removal * Vendor dependencies for reproducable builds * Api tests are back
41 lines
619 B
Go
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
|
|
})
|
|
}
|