Skip to content

Commit 8ac9815

Browse files
authored
CDRIVER-3902 expect success when no expectResult/expectError is included (#734)
1 parent 8c202f4 commit 8ac9815

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/libmongoc/tests/unified/operation.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,8 @@ operation_with_transaction (test_t *test,
20492049
mongoc_client_session_with_transaction (
20502050
session, with_transaction_cb, topts, &tctx, &op_reply, &op_error);
20512051

2052+
result_from_val_and_reply (result, NULL, &op_reply, &op_error);
2053+
20522054
ret = true;
20532055
done:
20542056
bson_parser_destroy_with_parsed_fields (bp);

src/libmongoc/tests/unified/result.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,11 @@ result_check (result_t *result,
338338
bson_val_t *error_expect_result;
339339

340340
if (!expect_result && !expect_error) {
341-
/* TODO: "create index on a non-existing collection" seems to assume no
342-
* "expectResult" or "expectError" means no check. */
341+
if (!result->ok) {
342+
test_set_error (
343+
error, "expected success, but got error: %s", result->error.message);
344+
goto done;
345+
}
343346
ret = true;
344347
goto done;
345348
}

src/libmongoc/tests/unified/runner.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ test_setup_initial_data (test_t *test, bson_error_t *error)
732732
/* This is not a "ns not found" error. Fail the test. */
733733
goto loopexit;
734734
}
735+
/* Clear an "ns not found" error. */
736+
memset (error, 0, sizeof (bson_error_t));
735737
}
736738

737739
/* Insert documents if specified. */

0 commit comments

Comments
 (0)