mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-23 23:55:02 +01:00
40 lines
881 B
Go
40 lines
881 B
Go
package responses
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestBadAuthErrorsNotAllowedForSentry(t *testing.T) {
|
|
badAuthErrResponse := echo.NewHTTPError(http.StatusBadRequest, echo.Map{
|
|
"error": true,
|
|
"code": 1,
|
|
"message": "bad auth",
|
|
})
|
|
|
|
isAllowed := isErrAllowedForSentry(badAuthErrResponse)
|
|
assert.False(t, isAllowed)
|
|
}
|
|
|
|
func TestNotBadAuthErrorsAllowedForSentry(t *testing.T) {
|
|
notBadAuthErrResponse := echo.NewHTTPError(http.StatusBadRequest, echo.Map{
|
|
"error": true,
|
|
"code": 2,
|
|
"message": "not bad auth",
|
|
})
|
|
|
|
isAllowed := isErrAllowedForSentry(notBadAuthErrResponse)
|
|
assert.True(t, isAllowed)
|
|
}
|
|
|
|
func TestNonErrorResponseErrorsAllowedForSentry(t *testing.T) {
|
|
err := errors.New("random error")
|
|
|
|
isAllowed := isErrAllowedForSentry(err)
|
|
assert.True(t, isAllowed)
|
|
}
|