@@ -23,6 +23,8 @@ import (
2323 "go.mongodb.org/mongo-driver/mongo"
2424 "go.mongodb.org/mongo-driver/mongo/integration/mtest"
2525 "go.mongodb.org/mongo-driver/mongo/options"
26+ "go.mongodb.org/mongo-driver/x/mongo/driver"
27+ "go.mongodb.org/mongo-driver/x/mongo/driver/topology"
2628)
2729
2830type netErr struct {
@@ -515,13 +517,25 @@ func TestErrors(t *testing.T) {
515517 err error
516518 result bool
517519 }{
518- {"context timeout" , mongo.CommandError {100 , "" , []string {"other" }, "blah" , context .DeadlineExceeded , nil }, true },
519- {"ServerError NetworkTimeoutError" , mongo.CommandError {100 , "" , []string {"NetworkTimeoutError" }, "blah" , nil , nil }, true },
520- {"ServerError ExceededTimeLimitError" , mongo.CommandError {100 , "" , []string {"ExceededTimeLimitError" }, "blah" , nil , nil }, true },
521- {"ServerError false" , mongo.CommandError {100 , "" , []string {"other" }, "blah" , nil , nil }, false },
522- {"net error true" , mongo.CommandError {100 , "" , []string {"other" }, "blah" , netErr {true }, nil }, true },
520+ {"context timeout" , mongo.CommandError {
521+ 100 , "" , []string {"other" }, "blah" , context .DeadlineExceeded , nil }, true },
522+ {"deadline would be exceeded" , mongo.CommandError {
523+ 100 , "" , []string {"other" }, "blah" , driver .ErrDeadlineWouldBeExceeded , nil }, true },
524+ {"server selection timeout" , mongo.CommandError {
525+ 100 , "" , []string {"other" }, "blah" , topology .ErrServerSelectionTimeout , nil }, true },
526+ {"wait queue timeout" , mongo.CommandError {
527+ 100 , "" , []string {"other" }, "blah" , topology.WaitQueueTimeoutError {}, nil }, true },
528+ {"ServerError NetworkTimeoutError" , mongo.CommandError {
529+ 100 , "" , []string {"NetworkTimeoutError" }, "blah" , nil , nil }, true },
530+ {"ServerError ExceededTimeLimitError" , mongo.CommandError {
531+ 100 , "" , []string {"ExceededTimeLimitError" }, "blah" , nil , nil }, true },
532+ {"ServerError false" , mongo.CommandError {
533+ 100 , "" , []string {"other" }, "blah" , nil , nil }, false },
534+ {"net error true" , mongo.CommandError {
535+ 100 , "" , []string {"other" }, "blah" , netErr {true }, nil }, true },
523536 {"net error false" , netErr {false }, false },
524- {"wrapped error" , wrappedError {mongo.CommandError {100 , "" , []string {"other" }, "blah" , context .DeadlineExceeded , nil }}, true },
537+ {"wrapped error" , wrappedError {mongo.CommandError {
538+ 100 , "" , []string {"other" }, "blah" , context .DeadlineExceeded , nil }}, true },
525539 {"other error" , errors .New ("foo" ), false },
526540 }
527541 for _ , tc := range testCases {
0 commit comments