traefik/safe/routine_test.go
Emile Vauge 5a67d0ac84
Fix panic in k8s loadIngresses
Signed-off-by: Emile Vauge <emile@vauge.com>
2017-02-03 09:46:27 +01:00

37 lines
837 B
Go

package safe
import (
"fmt"
"github.com/cenk/backoff"
"testing"
)
func TestOperationWithRecover(t *testing.T) {
operation := func() error {
return nil
}
err := backoff.Retry(OperationWithRecover(operation), &backoff.StopBackOff{})
if err != nil {
t.Fatalf("Error in OperationWithRecover: %s", err)
}
}
func TestOperationWithRecoverPanic(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)
}
}
func TestOperationWithRecoverError(t *testing.T) {
operation := func() error {
return fmt.Errorf("ERROR")
}
err := backoff.Retry(OperationWithRecover(operation), &backoff.StopBackOff{})
if err == nil {
t.Fatalf("Error in OperationWithRecover: %s", err)
}
}