@@ -2744,31 +2744,41 @@ func TestClientRequestObjectsWithPassedCanceledContext(t *testing.T) {
27442744 }
27452745}
27462746
2747- func TestComparableCanceledContextErrors (t * testing.T ) {
2747+ // Checking comparable with simple context.WithCancel.
2748+ func TestComparableErrorsCanceledContext (t * testing.T ) {
27482749 conn := test_helpers .ConnectWithValidation (t , dialer , opts )
27492750 defer conn .Close ()
27502751
2751- // Checking comparable with simple context.WithCancel.
27522752 ctx , cancel := context .WithCancel (context .Background ())
27532753 req := NewPingRequest ().Context (ctx )
27542754 cancel ()
27552755 _ , err := conn .Do (req ).Get ()
27562756 require .True (t , errors .Is (err , context .Canceled ), err .Error ())
2757+ }
2758+
2759+ // Checking comparable with simple context.WithTimeout.
2760+ func TestComparableErrorsTimeoutContext (t * testing.T ) {
2761+ conn := test_helpers .ConnectWithValidation (t , dialer , opts )
2762+ defer conn .Close ()
27572763
2758- // Checking comparable with simple context.WithTimeout.
27592764 timeout := time .Nanosecond
2760- ctx , cancel = context .WithTimeout (context .Background (), timeout )
2761- req = NewPingRequest ().Context (ctx )
2765+ ctx , cancel : = context .WithTimeout (context .Background (), timeout )
2766+ req : = NewPingRequest ().Context (ctx )
27622767 defer cancel ()
2763- _ , err = conn .Do (req ).Get ()
2768+ _ , err : = conn .Do (req ).Get ()
27642769 require .True (t , errors .Is (err , context .DeadlineExceeded ), err .Error ())
2770+ }
2771+
2772+ // Checking comparable with context.WithCancelCause.
2773+ // Shows ability to compare with custom errors (also with ClientError).
2774+ func TestComparableErrorsCancelCauseContext (t * testing.T ) {
2775+ conn := test_helpers .ConnectWithValidation (t , dialer , opts )
2776+ defer conn .Close ()
27652777
2766- // Checking comparable with context.WithCancelCause.
2767- // Shows ability to compare with custom errors (also with ClientError).
27682778 ctxCause , cancelCause := context .WithCancelCause (context .Background ())
2769- req = NewPingRequest ().Context (ctxCause )
2779+ req : = NewPingRequest ().Context (ctxCause )
27702780 cancelCause (ClientError {ErrConnectionClosed , "something went wrong" })
2771- _ , err = conn .Do (req ).Get ()
2781+ _ , err : = conn .Do (req ).Get ()
27722782 var tmpErr ClientError
27732783 require .True (t , errors .As (err , & tmpErr ), tmpErr .Error ())
27742784}
0 commit comments