forked from TrueCloudLab/frostfs-sdk-go
[#278] pool: Avoid using strings.Contains
for error assertion
`client` package now provides functions for error checking. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
dcaf454c1d
commit
1e1139f305
2 changed files with 4 additions and 6 deletions
|
@ -10,7 +10,6 @@ import (
|
|||
"math"
|
||||
"math/rand"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -1225,8 +1224,7 @@ func (p *Pool) checkSessionTokenErr(err error, address string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
if strings.Contains(err.Error(), "session token does not exist") ||
|
||||
strings.Contains(err.Error(), "session token has been expired") {
|
||||
if sdkClient.IsErrSessionNotFound(err) || sdkClient.IsErrSessionExpired(err) {
|
||||
p.cache.DeleteByPrefix(address)
|
||||
return true
|
||||
}
|
||||
|
@ -1768,8 +1766,7 @@ func waitForContainerRemoved(ctx context.Context, cli client, cnrID *cid.ID, wai
|
|||
|
||||
return waitFor(ctx, waitParams, func(ctx context.Context) bool {
|
||||
_, err := cli.containerGet(ctx, prm)
|
||||
return sdkClient.IsErrContainerNotFound(err) ||
|
||||
err != nil && strings.Contains(err.Error(), "not found")
|
||||
return sdkClient.IsErrContainerNotFound(err)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/golang/mock/gomock"
|
||||
"github.com/google/uuid"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/container"
|
||||
neofsecdsa "github.com/nspcc-dev/neofs-sdk-go/crypto/ecdsa"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
|
@ -387,7 +388,7 @@ func TestSessionCache(t *testing.T) {
|
|||
}).MaxTimes(3)
|
||||
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
|
||||
|
||||
mockClient.EXPECT().objectGet(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("session token does not exist"))
|
||||
mockClient.EXPECT().objectGet(gomock.Any(), gomock.Any()).Return(nil, apistatus.SessionTokenNotFound{})
|
||||
mockClient.EXPECT().objectPut(gomock.Any(), gomock.Any()).Return(nil, nil)
|
||||
|
||||
return mockClient, nil
|
||||
|
|
Loading…
Reference in a new issue