Skip to content

Commit 5ab8f15

Browse files
committed
GODRIVER-3140 Update help function.
1 parent 18a7e7e commit 5ab8f15

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

mongo/integration/json_helpers_test.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ func createClientOptions(t testing.TB, opts bson.Raw) *options.ClientOptions {
114114
case "socketTimeoutMS":
115115
st := convertValueToMilliseconds(t, opt)
116116
clientOpts.SetSocketTimeout(st)
117+
case "timeoutMS":
118+
clientOpts.SetTimeout(time.Duration(opt.Int32()) * time.Millisecond)
117119
case "minPoolSize":
118120
clientOpts.SetMinPoolSize(uint64(opt.AsInt64()))
119121
case "maxPoolSize":
@@ -470,8 +472,9 @@ func errorFromResult(t testing.TB, result interface{}) *operationError {
470472
if err != nil {
471473
return nil
472474
}
473-
if expected.ErrorCodeName == nil && expected.ErrorContains == nil && len(expected.ErrorLabelsOmit) == 0 &&
474-
len(expected.ErrorLabelsContain) == 0 {
475+
if expected.ErrorCodeName == nil && expected.ErrorContains == nil &&
476+
len(expected.ErrorLabelsOmit) == 0 && len(expected.ErrorLabelsContain) == 0 &&
477+
expected.IsTimeoutError == nil {
475478
return nil
476479
}
477480

@@ -563,6 +566,13 @@ func verifyError(expected *operationError, actual error) error {
563566
return fmt.Errorf("expected error %w to not contain label %q", actual, label)
564567
}
565568
}
569+
if expected.IsTimeoutError != nil {
570+
isTimeoutError := mongo.IsTimeout(actual)
571+
if *expected.IsTimeoutError != isTimeoutError {
572+
return fmt.Errorf("expected error %w to be a timeout error: %v, is timeout error: %v",
573+
actual, *expected.IsTimeoutError, isTimeoutError)
574+
}
575+
}
566576
return nil
567577
}
568578

mongo/integration/unified_spec_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ type operationError struct {
175175
ErrorCodeName *string `bson:"errorCodeName"`
176176
ErrorLabelsContain []string `bson:"errorLabelsContain"`
177177
ErrorLabelsOmit []string `bson:"errorLabelsOmit"`
178+
IsTimeoutError *bool `bson:"isTimeoutError"`
178179
}
179180

180181
const dataPath string = "../../testdata/"

0 commit comments

Comments
 (0)