diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2020-04-20 10:11:46 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-21 17:41:43 +0000 |
commit | 3ebb641b1c0fb63243e801b966ccde1167fdada9 (patch) | |
tree | 62f195d7c2579249fe5e2d48c38873720c22c106 /src/mongo/logv2 | |
parent | 0da8219526b074f3594d257610c8155c624f43a7 (diff) | |
download | mongo-3ebb641b1c0fb63243e801b966ccde1167fdada9.tar.gz |
SERVER-47614 Fix logv2_test when running with increased verbosity.
Diffstat (limited to 'src/mongo/logv2')
-rw-r--r-- | src/mongo/logv2/logv2_test.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mongo/logv2/logv2_test.cpp b/src/mongo/logv2/logv2_test.cpp index 94d9e646c68..7fe66eaff01 100644 --- a/src/mongo/logv2/logv2_test.cpp +++ b/src/mongo/logv2/logv2_test.cpp @@ -1590,14 +1590,17 @@ TEST_F(LogV2Test, UserAssert) { sink->set_formatter(PlainFormatter()); attachSink(sink); + // Depending on verbosity set the assertion code may emit additional log messages after ours, + // disregard them when verifying by clearing lines after every test ASSERT_THROWS_WITH_CHECK( LOGV2_OPTIONS(4652000, {UserAssertAfterLog(ErrorCodes::BadValue)}, "uasserting log"), DBException, [&lines](const DBException& ex) { ASSERT_EQUALS(ex.code(), ErrorCodes::BadValue); ASSERT_EQUALS(ex.reason(), "uasserting log"); - ASSERT_EQUALS(lines.back(), ex.reason()); + ASSERT_EQUALS(lines.front(), ex.reason()); }); + lines.clear(); ASSERT_THROWS_WITH_CHECK(LOGV2_OPTIONS(4652001, {UserAssertAfterLog(ErrorCodes::BadValue)}, @@ -1607,15 +1610,16 @@ TEST_F(LogV2Test, UserAssert) { [&lines](const DBException& ex) { ASSERT_EQUALS(ex.code(), ErrorCodes::BadValue); ASSERT_EQUALS(ex.reason(), "uasserting log 1"); - ASSERT_EQUALS(lines.back(), ex.reason()); + ASSERT_EQUALS(lines.front(), ex.reason()); }); + lines.clear(); ASSERT_THROWS_WITH_CHECK(LOGV2_OPTIONS(4716000, {UserAssertAfterLog()}, "uasserting log"), DBException, [&lines](const DBException& ex) { ASSERT_EQUALS(ex.code(), 4716000); ASSERT_EQUALS(ex.reason(), "uasserting log"); - ASSERT_EQUALS(lines.back(), ex.reason()); + ASSERT_EQUALS(lines.front(), ex.reason()); }); } |