summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-01-15 17:00:23 -0500
committerBenety Goh <benety@mongodb.com>2019-01-15 17:00:50 -0500
commit8380f273705cb6cb8705526dfbdfb01ad022de8e (patch)
treef8c20e41f9f2d30a1d881547c40672f96f81c221
parent78a8fa36593cc0c429ffe10e07ccc33f7ce81d27 (diff)
downloadmongo-8380f273705cb6cb8705526dfbdfb01ad022de8e.tar.gz
SERVER-37829 clean up service context on test assertion
add stitch error details to checkUpdate assertion message
-rw-r--r--src/mongo/embedded/stitch_support/stitch_support_test.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/mongo/embedded/stitch_support/stitch_support_test.cpp b/src/mongo/embedded/stitch_support/stitch_support_test.cpp
index 56e82e7d2f7..ba43a9267c1 100644
--- a/src/mongo/embedded/stitch_support/stitch_support_test.cpp
+++ b/src/mongo/embedded/stitch_support/stitch_support_test.cpp
@@ -36,10 +36,13 @@
#include "mongo/bson/json.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/quick_exit.h"
+#include "mongo/util/scopeguard.h"
namespace {
using mongo::fromjson;
+using mongo::makeGuard;
+using mongo::ScopeGuard;
class StitchSupportTest : public mongo::unittest::Test {
protected:
@@ -110,6 +113,7 @@ protected:
collator =
stitch_support_v1_collator_create(lib, fromjson(collatorObj).objdata(), nullptr);
}
+ ON_BLOCK_EXIT([collator] { stitch_support_v1_collator_destroy(collator); });
stitch_support_v1_matcher* matcher = nullptr;
if (match) {
@@ -117,6 +121,7 @@ protected:
stitch_support_v1_matcher_create(lib, fromjson(match).objdata(), collator, nullptr);
ASSERT(matcher);
}
+ ON_BLOCK_EXIT([matcher] { stitch_support_v1_matcher_destroy(matcher); });
stitch_support_v1_update* update = stitch_support_v1_update_create(
lib,
@@ -126,19 +131,17 @@ protected:
collator,
status);
ASSERT(update);
+ ON_BLOCK_EXIT([update] { stitch_support_v1_update_destroy(update); });
char* updateResult = stitch_support_v1_update_apply(
update, fromjson(document).objdata(), updateDetails, status);
- ASSERT_EQ(0, stitch_support_v1_status_get_code(status));
+ ASSERT_EQ(0, stitch_support_v1_status_get_code(status))
+ << stitch_support_v1_status_get_error(status) << ":"
+ << stitch_support_v1_status_get_explanation(status);
ASSERT(updateResult);
-
- stitch_support_v1_update_destroy(update);
- stitch_support_v1_matcher_destroy(matcher);
- stitch_support_v1_collator_destroy(collator);
+ ON_BLOCK_EXIT([updateResult] { free(updateResult); });
ASSERT_BSONOBJ_EQ(mongo::BSONObj(updateResult), expectedResult);
-
- free(updateResult);
}
const std::string getModifiedPaths() {