github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/ratelimiter/errors/errors_test.go (about) 1 package errors 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors" 8 ) 9 10 func TestIsAcquireError(t *testing.T) { 11 for _, err := range []error{ 12 &acquireError{}, 13 xerrors.WithStackTrace(&acquireError{}), 14 xerrors.WithStackTrace(fmt.Errorf("%w", &acquireError{})), 15 } { 16 t.Run("", func(t *testing.T) { 17 if !IsAcquireError(err) { 18 t.Errorf("not acquire error: %v", err) 19 } 20 }) 21 } 22 } 23 24 func TestToAcquireError(t *testing.T) { 25 for _, err := range []error{ 26 &acquireError{}, 27 xerrors.WithStackTrace(&acquireError{}), 28 xerrors.WithStackTrace(fmt.Errorf("%w", &acquireError{})), 29 } { 30 t.Run("", func(t *testing.T) { 31 ae := ToAcquireError(err) 32 if ae == nil { 33 t.Errorf("not acquire error: %v", err) 34 } 35 }) 36 } 37 }