2022-06-27 07:24:17 +00:00
|
|
|
package client_test
|
|
|
|
|
|
|
|
import (
|
2022-06-27 07:39:20 +00:00
|
|
|
"fmt"
|
2022-06-27 07:24:17 +00:00
|
|
|
"testing"
|
|
|
|
|
2023-03-07 11:20:03 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
|
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
2022-06-27 07:24:17 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestErrors(t *testing.T) {
|
|
|
|
for _, tc := range []struct {
|
|
|
|
check func(error) bool
|
|
|
|
errs []error
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
check: client.IsErrContainerNotFound,
|
|
|
|
errs: []error{
|
|
|
|
apistatus.ContainerNotFound{},
|
|
|
|
new(apistatus.ContainerNotFound),
|
|
|
|
},
|
|
|
|
},
|
2022-08-01 14:17:48 +00:00
|
|
|
{
|
|
|
|
check: client.IsErrEACLNotFound,
|
|
|
|
errs: []error{
|
|
|
|
apistatus.EACLNotFound{},
|
|
|
|
new(apistatus.EACLNotFound),
|
|
|
|
},
|
|
|
|
},
|
2022-06-27 07:24:17 +00:00
|
|
|
{
|
|
|
|
check: client.IsErrObjectNotFound,
|
|
|
|
errs: []error{
|
|
|
|
apistatus.ObjectNotFound{},
|
|
|
|
new(apistatus.ObjectNotFound),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
check: client.IsErrObjectAlreadyRemoved,
|
|
|
|
errs: []error{
|
|
|
|
apistatus.ObjectAlreadyRemoved{},
|
|
|
|
new(apistatus.ObjectAlreadyRemoved),
|
|
|
|
},
|
|
|
|
},
|
2022-06-27 07:45:43 +00:00
|
|
|
{
|
|
|
|
check: client.IsErrSessionExpired,
|
|
|
|
errs: []error{
|
|
|
|
apistatus.SessionTokenExpired{},
|
|
|
|
new(apistatus.SessionTokenExpired),
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
check: client.IsErrSessionNotFound,
|
|
|
|
errs: []error{
|
|
|
|
apistatus.SessionTokenNotFound{},
|
|
|
|
new(apistatus.SessionTokenNotFound),
|
|
|
|
},
|
|
|
|
},
|
2022-06-27 07:24:17 +00:00
|
|
|
} {
|
|
|
|
require.NotEmpty(t, tc.errs)
|
|
|
|
|
|
|
|
for i := range tc.errs {
|
|
|
|
require.True(t, tc.check(tc.errs[i]), tc.errs[i])
|
2022-06-27 18:30:06 +00:00
|
|
|
require.True(t, tc.check(fmt.Errorf("top-level context: :%w",
|
|
|
|
fmt.Errorf("inner context: %w", tc.errs[i])),
|
|
|
|
), tc.errs[i])
|
2022-06-27 07:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|