Add Operation with recover

This commit is contained in:
Emile Vauge 2016-12-08 13:32:12 +01:00
parent a394e6a3e3
commit be362f0d9f
No known key found for this signature in database
GPG key ID: D808B4C167352E59
11 changed files with 45 additions and 12 deletions

16
safe/routine_test.go Normal file
View file

@ -0,0 +1,16 @@
package safe
import (
"github.com/cenk/backoff"
"testing"
)
func TestOperationWithRecover(t *testing.T) {
operation := func() error {
panic("BOOM")
}
err := backoff.Retry(OperationWithRecover(operation), &backoff.StopBackOff{})
if err == nil {
t.Fatalf("Error in OperationWithRecover: %s", err)
}
}