Fix issue with uncommited transaction
This commit is contained in:
parent
24a30d0121
commit
7aadc1ad4a
|
@ -39,6 +39,11 @@ func addPeer(mHash string, status PeerStatus) {
|
|||
}
|
||||
_, err2 := tx.Exec(createPeer, mHash, status)
|
||||
if err2 != nil {
|
||||
// This .Commit() call never gets hit:
|
||||
err1 := tx.Rollback()
|
||||
if err1 != nil {
|
||||
panicf("Failed to rollback peer (1): %s", err)
|
||||
}
|
||||
panic(fmt.Sprintf("Failure. Possible duplicate peer?: %s", err2))
|
||||
}
|
||||
err1 := tx.Commit()
|
||||
|
|
|
@ -26,9 +26,9 @@ func TestGetPeerStatus(t *testing.T) {
|
|||
func TestAddPeer(t *testing.T) {
|
||||
defer func() {
|
||||
r := recover()
|
||||
if r != nil {
|
||||
err := "Should not be able to block and follow at the same time"
|
||||
t.Errorf(err)
|
||||
if r == nil {
|
||||
err := "Should not be able to block and follow at the same time %s"
|
||||
t.Errorf(err, r)
|
||||
}
|
||||
}()
|
||||
resetDB()
|
||||
|
|
Loading…
Reference in New Issue