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"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -1225,8 +1224,7 @@ func (p *Pool) checkSessionTokenErr(err error, address string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(err.Error(), "session token does not exist") ||
|
if sdkClient.IsErrSessionNotFound(err) || sdkClient.IsErrSessionExpired(err) {
|
||||||
strings.Contains(err.Error(), "session token has been expired") {
|
|
||||||
p.cache.DeleteByPrefix(address)
|
p.cache.DeleteByPrefix(address)
|
||||||
return true
|
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 {
|
return waitFor(ctx, waitParams, func(ctx context.Context) bool {
|
||||||
_, err := cli.containerGet(ctx, prm)
|
_, err := cli.containerGet(ctx, prm)
|
||||||
return sdkClient.IsErrContainerNotFound(err) ||
|
return sdkClient.IsErrContainerNotFound(err)
|
||||||
err != nil && strings.Contains(err.Error(), "not found")
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"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"
|
"github.com/nspcc-dev/neofs-sdk-go/container"
|
||||||
neofsecdsa "github.com/nspcc-dev/neofs-sdk-go/crypto/ecdsa"
|
neofsecdsa "github.com/nspcc-dev/neofs-sdk-go/crypto/ecdsa"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||||
|
@ -387,7 +388,7 @@ func TestSessionCache(t *testing.T) {
|
||||||
}).MaxTimes(3)
|
}).MaxTimes(3)
|
||||||
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
|
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)
|
mockClient.EXPECT().objectPut(gomock.Any(), gomock.Any()).Return(nil, nil)
|
||||||
|
|
||||||
return mockClient, nil
|
return mockClient, nil
|
||||||
|
|
Loading…
Reference in a new issue