bzs1118 commented on code in PR #3773:
URL: https://github.com/apache/brpc/pull/3773#discussion_r4729935254
##########
test/brpc_builtin_service_unittest.cpp:
##########
@@ -171,6 +172,26 @@ void CheckTraceId(const brpc::Controller& cntl,
ASSERT_TRUE(pos != std::string::npos) << expect_str;
}
+void CheckCreatedTimeNearNow(const brpc::Controller& cntl) {
+ const std::string& content = cntl.response_attachment().to_string();
+ const std::size_t header = content.find("CreatedTime");
+ ASSERT_NE(std::string::npos, header) << content;
+ const std::size_t header_end = content.find('\n', header);
+ ASSERT_NE(std::string::npos, header_end) << content;
+ const std::size_t col_end = content.find('|', header_end);
+ ASSERT_NE(std::string::npos, col_end) << content;
+ const std::string created =
+ content.substr(header_end + 1, col_end - header_end - 1);
+
+ const int64_t now_us = butil::gettimeofday_us();
+ std::ostringstream lower;
+ std::ostringstream upper;
+ brpc::PrintRealDateTime(lower, now_us - 600 * 1000000L);
+ brpc::PrintRealDateTime(upper, now_us + 600 * 1000000L);
+ ASSERT_GE(created, lower.str()) << "CreatedTime=" << created;
+ ASSERT_LE(created, upper.str()) << "CreatedTime=" << created;
Review Comment:
How about only comare "year" (accepting the previous year for the New Year
boundary)? The test now only parses the year from the rendered CreatedTime.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]