rclone/vendor/github.com/pengsrc/go-shared/utils/recover_test.go
2018-06-17 17:59:12 +01:00

31 lines
471 B
Go

package utils
import (
"context"
"io/ioutil"
"sync"
"testing"
"github.com/stretchr/testify/assert"
"github.com/pengsrc/go-shared/log"
)
func TestRecover(t *testing.T) {
discardLogger, err := log.NewLogger(ioutil.Discard)
assert.NoError(t, err)
log.SetGlobalLogger(discardLogger)
defer log.SetGlobalLogger(nil)
ctx := context.Background()
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer Recover(ctx)
wg.Done()
panic("fear")
}()
wg.Wait()
}