@@ -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,8 @@ 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
+
2738
+ if ! contextDoneErrRegexp .Match ([]byte (err .Error ())) {
2735
2739
t .Fatalf ("Failed to catch an error from done context" )
2736
2740
}
2737
2741
if resp != nil {
@@ -2802,7 +2806,7 @@ func TestClientRequestObjectsWithContext(t *testing.T) {
2802
2806
if err == nil {
2803
2807
t .Fatalf ("caught nil error" )
2804
2808
}
2805
- if ! strings . HasPrefix ( err .Error (), "context is done" ) {
2809
+ if ! contextDoneErrRegexp . Match ([] byte ( err .Error ()) ) {
2806
2810
t .Fatalf ("wrong error caught: %v" , err )
2807
2811
}
2808
2812
}
@@ -3295,7 +3299,7 @@ func TestClientIdRequestObjectWithPassedCanceledContext(t *testing.T) {
3295
3299
resp , err := conn .Do (req ).Get ()
3296
3300
require .Nilf (t , resp , "Response is empty" )
3297
3301
require .NotNilf (t , err , "Error is not empty" )
3298
- require .ErrorContains (t , err , "context is done" )
3302
+ require .Regexp (t , contextDoneErrRegexp , err . Error () )
3299
3303
}
3300
3304
3301
3305
func TestConnectionProtocolInfoUnsupported (t * testing.T ) {
0 commit comments