telebot/middleware/middleware_test.go
Кобелев Андрей Андреевич 1b497f2b9b init
2023-02-01 12:08:20 +03:00

31 lines
492 B
Go

package middleware
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
tele "git.belvedersky.ru/common/telebot"
)
var b, _ = tele.NewBot(tele.Settings{Offline: true})
func TestRecover(t *testing.T) {
onError := func(err error) {
require.Error(t, err, "recover test")
}
h := func(c tele.Context) error {
panic("recover test")
}
assert.Panics(t, func() {
h(nil)
})
assert.NotPanics(t, func() {
Recover(onError)(h)(nil)
})
}