Skip to content

Commit

Permalink
SERVER-37829 clean up service context on test assertion
Browse files Browse the repository at this point in the history
add stitch error details to checkUpdate assertion message
  • Loading branch information
benety committed Jan 15, 2019
1 parent 78a8fa3 commit 8380f27
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/mongo/embedded/stitch_support/stitch_support_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -110,13 +113,15 @@ class StitchSupportTest : public mongo::unittest::Test {
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) {
matcher =
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,
Expand All @@ -126,19 +131,17 @@ class StitchSupportTest : public mongo::unittest::Test {
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() {
Expand Down

0 comments on commit 8380f27

Please sign in to comment.