frostfs-sdk-go/client/errors_test.go
nesterfifa e523bde976
Some checks reported warnings
Tests and linters / Lint (pull_request) Has been cancelled
Tests and linters / Tests (1.19) (pull_request) Has been cancelled
Tests and linters / Tests (1.20) (pull_request) Has been cancelled
DCO / DCO (pull_request) Has been cancelled
[#xxx] client: add error node maintenance
Signed-off-by: Viktor Nesterenko <vemeyzer@gmail.com>
2023-10-06 15:10:20 +02:00

52 lines
1.2 KiB
Go

package client_test
import (
"fmt"
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
"github.com/stretchr/testify/require"
)
func TestErrors(t *testing.T) {
errs := []struct {
check func(error) bool
err error
}{
{
check: client.IsErrContainerNotFound,
err: new(apistatus.ContainerNotFound),
},
{
check: client.IsErrEACLNotFound,
err: new(apistatus.EACLNotFound),
},
{
check: client.IsErrObjectNotFound,
err: new(apistatus.ObjectNotFound),
},
{
check: client.IsErrObjectAlreadyRemoved,
err: new(apistatus.ObjectAlreadyRemoved),
},
{
check: client.IsErrSessionExpired,
err: new(apistatus.SessionTokenExpired),
}, {
check: client.IsErrSessionNotFound,
err: new(apistatus.SessionTokenNotFound),
}, {
check: client.IsErrMaintenance,
err: new(apistatus.NodeUnderMaintenance),
},
}
for i := range errs {
for j := range errs {
nestedErr := fmt.Errorf("top-level context: :%w", fmt.Errorf("inner context: %w", errs[j].err))
require.Equal(t, i == j, errs[i].check(errs[j].err))
require.Equal(t, i == j, errs[i].check(nestedErr))
}
}
}