2023-04-03 11:04:35 +00:00
|
|
|
package services
|
2023-03-14 14:31:15 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/layer"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHandleError(t *testing.T) {
|
|
|
|
defaultError := errors.New("default error")
|
|
|
|
for _, tc := range []struct {
|
|
|
|
err error
|
|
|
|
expectedError error
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
err: defaultError,
|
|
|
|
expectedError: defaultError,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
err: errors.New("something not found"),
|
|
|
|
expectedError: layer.ErrNodeNotFound,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
err: errors.New("something is denied by some acl rule"),
|
|
|
|
expectedError: layer.ErrNodeAccessDenied,
|
|
|
|
},
|
|
|
|
} {
|
|
|
|
t.Run("", func(t *testing.T) {
|
|
|
|
err := handleError("err message", tc.err)
|
|
|
|
require.True(t, errors.Is(err, tc.expectedError))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|