@@ -11,6 +11,7 @@ import (
11
11
"os/exec"
12
12
"path/filepath"
13
13
"reflect"
14
+ "regexp"
14
15
"runtime"
15
16
"strings"
16
17
"sync"
@@ -47,6 +48,8 @@ type Member struct {
47
48
Val uint
48
49
}
49
50
51
+ var contextDoneErrRegexp = regexp .MustCompile (`^context is done \(request ID [0-9]+\)$` )
52
+
50
53
func (m * Member ) EncodeMsgpack (e * msgpack.Encoder ) error {
51
54
if err := e .EncodeArrayLen (2 ); err != nil {
52
55
return err
@@ -2731,7 +2734,7 @@ func TestClientRequestObjectsWithPassedCanceledContext(t *testing.T) {
2731
2734
req := NewPingRequest ().Context (ctx )
2732
2735
cancel ()
2733
2736
resp , err := conn .Do (req ).Get ()
2734
- if ! strings . HasPrefix ( err .Error (), "context is done" ) {
2737
+ if ! contextDoneErrRegexp . Match ([] byte ( err .Error ()) ) {
2735
2738
t .Fatalf ("Failed to catch an error from done context" )
2736
2739
}
2737
2740
if resp != nil {
@@ -2802,7 +2805,7 @@ func TestClientRequestObjectsWithContext(t *testing.T) {
2802
2805
if err == nil {
2803
2806
t .Fatalf ("caught nil error" )
2804
2807
}
2805
- if ! strings . HasPrefix ( err .Error (), "context is done" ) {
2808
+ if ! contextDoneErrRegexp . Match ([] byte ( err .Error ()) ) {
2806
2809
t .Fatalf ("wrong error caught: %v" , err )
2807
2810
}
2808
2811
}
@@ -3295,7 +3298,7 @@ func TestClientIdRequestObjectWithPassedCanceledContext(t *testing.T) {
3295
3298
resp , err := conn .Do (req ).Get ()
3296
3299
require .Nilf (t , resp , "Response is empty" )
3297
3300
require .NotNilf (t , err , "Error is not empty" )
3298
- require .ErrorContains (t , err , "context is done" )
3301
+ require .Regexp (t , contextDoneErrRegexp , err . Error () )
3299
3302
}
3300
3303
3301
3304
func TestConnectionProtocolInfoUnsupported (t * testing.T ) {
0 commit comments