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), }, } 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)) } } }