@@ -13,7 +13,7 @@ func TestCancelWithError(t *testing.T) {
1313 t .Run ("SimpleCancel" , func (t * testing.T ) {
1414 ctx , cancel := WithErrCancel (context .Background ())
1515 cancel (testError )
16- require .Equal (t , testError , ctx .Err ())
16+ require .ErrorIs (t , ctx .Err (), testError )
1717 })
1818
1919 t .Run ("CancelBeforeParent" , func (t * testing.T ) {
@@ -23,7 +23,8 @@ func TestCancelWithError(t *testing.T) {
2323 cancel (testError )
2424 parentCancel ()
2525
26- require .Equal (t , testError , ctx .Err ())
26+ require .ErrorIs (t , ctx .Err (), testError )
27+ require .ErrorIs (t , ctx .Err (), context .Canceled )
2728 })
2829
2930 t .Run ("CancelAfterParent" , func (t * testing.T ) {
@@ -36,4 +37,10 @@ func TestCancelWithError(t *testing.T) {
3637 require .Equal (t , context .Canceled , ctx .Err ())
3738 })
3839
40+ t .Run ("CancelWithNil" , func (t * testing.T ) {
41+ ctx , cancel := WithErrCancel (context .Background ())
42+ cancel (nil )
43+ require .ErrorIs (t , ctx .Err (), errCancelWithNilError )
44+ require .ErrorIs (t , ctx .Err (), context .Canceled )
45+ })
3946}
0 commit comments