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

59 lines
1.1 KiB
Go

package testdb
import (
"errors"
"testing"
)
func TestTxSetCommitFunc(t *testing.T) {
tx := &Tx{}
tx.SetCommitFunc(func() error {
return errors.New("commit failed")
})
err := tx.Commit()
if err == nil || err.Error() != "commit failed" {
t.Fatal("stubbed commit did not return expected error")
}
}
func TestTxStubCommitError(t *testing.T) {
tx := &Tx{}
tx.StubCommitError(errors.New("commit failed"))
err := tx.Commit()
if err == nil || err.Error() != "commit failed" {
t.Fatal("stubbed commit did not return expected error")
}
}
func TestTxSetRollbackFunc(t *testing.T) {
tx := &Tx{}
tx.SetRollbackFunc(func() error {
return errors.New("rollback failed")
})
err := tx.Rollback()
if err == nil || err.Error() != "rollback failed" {
t.Fatal("stubbed rollback did not return expected error")
}
}
func TestTxStubRollbackError(t *testing.T) {
tx := &Tx{}
tx.StubRollbackError(errors.New("rollback failed"))
err := tx.Rollback()
if err == nil || err.Error() != "rollback failed" {
t.Fatal("stubbed rollback did not return expected error")
}
}